diff --git a/.travis.yml b/.travis.yml
index 51b62e240e9..4b17ebaf0c8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
# from Dolibarr GitHub repository.
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/
-# We use dist: precise to have php 5.3 available
+# We use dist: trusty to have php 5.4+ available
dist: trusty
sudo: required
@@ -20,7 +20,7 @@ addons:
# To use the last version of pgloader, we add repo of postgresql
- postgresql
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
- - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
+ - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
packages:
# We need a webserver to test the webservices
# Let's install Apache with.
@@ -37,7 +37,6 @@ php:
- '7.0'
- '7.1'
- '7.2'
-#- hhvm only with dist: trusty
- nightly
env:
@@ -59,10 +58,17 @@ env:
matrix:
fast_finish: true
allow_failures:
- - php: hhvm
- php: nightly
# We exclude some combinations not usefull to save Travis CPU
exclude:
+ - php: '5.5'
+ env: DB=mariadb
+ - php: '5.6'
+ env: DB=mariadb
+ - php: '7.0'
+ env: DB=mariadb
+ - php: '7.1'
+ env: DB=mariadb
- php: '5.5'
env: DB=postgresql
- php: '5.6'
@@ -71,8 +77,6 @@ matrix:
env: DB=postgresql
- php: '7.1'
env: DB=postgresql
- - php: hhvm
- env: DB=postgresql
- php: nightly
env: DB=postgresql
@@ -101,7 +105,7 @@ before_install:
pgloader --version
echo
fi
-
+
install:
- |
echo "Updating Composer"
@@ -133,7 +137,7 @@ install:
- |
echo "Installing PHP CodeSniffer"
- composer -n require squizlabs/php_codesniffer ^2
+ composer -n require squizlabs/php_codesniffer ^3
echo
- |
@@ -195,7 +199,7 @@ before_script:
mysql --version | head -
mysql -e "SELECT VERSION();" | head -
echo
-
+
- |
echo "Setting up database"
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then
@@ -203,12 +207,11 @@ before_script:
mysql -e 'DROP DATABASE IF EXISTS travis;'
mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
- mysql -e 'FLUSH PRIVILEGES;'
+ mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
fi
if [ "$DB" = 'postgresql' ]; then
- #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
- #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr
+ #pgloader mysql://root:pass@127.0.0.1/dolibarr_35 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev
pgloader mysql://root@127.0.0.1/travis postgresql:///travis
fi
# TODO: SQLite
@@ -217,7 +220,7 @@ before_script:
- |
export CONF_FILE=htdocs/conf/conf.php
echo "Setting up Dolibarr $CONF_FILE"
- echo ' $CONF_FILE
+ echo ' $CONF_FILE
echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE
echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE
echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE
@@ -238,8 +241,9 @@ before_script:
- |
echo "Create documents directory and set permissions"
# and admin/temp subdirectory needed for unit tests
- mkdir -p documents/admin/temp
- echo "first line" > documents/dolibarr.log
+ mkdir -p $TRAVIS_BUILD_DIR/documents/admin/temp
+ sudo chmod -R a+rwx $TRAVIS_BUILD_DIR/documents
+ echo "***** First line of dolibarr.log" > $TRAVIS_BUILD_DIR/documents/dolibarr.log
echo
@@ -334,32 +338,28 @@ script:
php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log
php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log
php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log
+ php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log
+ php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log
+ php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log
cd -
set +e
echo
- #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log
- #cat $TRAVIS_BUILD_DIR/upgrade500600.log
- #cat $TRAVIS_BUILD_DIR/upgrade500600-2.log
- #cat $TRAVIS_BUILD_DIR/upgrade500600-3.log
#cat /tmp/dolibarr_install.log
-
+
- |
echo "Unit testing"
# Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file.
set -e
phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php
+ phpunitresult=$?
+ echo "Phpunit return code = $phpunitresult"
set +e
-- |
- #echo "Output dolibarr.log"
- #cat documents/dolibarr.log
-
after_script:
- |
- # Dolibarr log file
- #echo "After script"
- #cat documents/dolibarr.log
-
+ echo "After script - Output 50 latest lines of dolibarr.log"
+ ls $TRAVIS_BUILD_DIR/documents
+ tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log
after_success:
- |
@@ -367,20 +367,24 @@ after_success:
after_failure:
- |
- echo Failure
- # This part of code seems to be never executed, error or not ???
- echo "Debugging informations"
+ echo Failure detected, so we show samples of log to help diagnose
+ # This part of code is executed only if previous commande that fails are enclosed with set +e
# Upgrade log files
- cat *.log
- echo "Debugging informations"
+ for ficlog in `ls $TRAVIS_BUILD_DIR/*.log`
+ do
+ echo "Debugging informations for file $ficlog"
+ #cat $ficlog
+ done
# Apache log file
+ echo "Debugging informations for file apache error.log"
sudo cat /var/log/apache2/error.log
- # Dolibarr log file
- cat documents/dolibarr.log
if [ "$DEBUG" = true ]; then
+ # Dolibarr log file
+ echo "Debugging informations for file dolibarr.log (latest 50 lines)"
+ tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log
# MariaDB log file
- sudo cat /var/log/mysql/error.log
+ echo "Debugging informations for file mysql error.log"
+ sudo tail -n 50 /var/log/mysql/error.log
# TODO: PostgreSQL log file
echo
fi
-
diff --git a/.tx/config b/.tx/config
index db380163540..27327f033ea 100644
--- a/.tx/config
+++ b/.tx/config
@@ -38,6 +38,12 @@ source_file = htdocs/langs/en_US/bills.lang
source_lang = en_US
type = MOZILLAPROPERTIES
+[dolibarr.blockedlog]
+file_filter = htdocs/langs//blockedlog.lang
+source_file = htdocs/langs/en_US/blockedlog.lang
+source_lang = en_US
+type = MOZILLAPROPERTIES
+
[dolibarr.bookmarks]
file_filter = htdocs/langs//bookmarks.lang
source_file = htdocs/langs/en_US/bookmarks.lang
diff --git a/ChangeLog b/ChangeLog
index fac6c0a3c06..891b27ba78f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,250 @@
English Dolibarr ChangeLog
--------------------------------------------------------------
+
+***** ChangeLog for 9.0.0 compared to 8.0.0 *****
+For Users:
+NEW: Stable module: Website
+NEW: Stable module: WebDAV
+NEW: Stable module: Module Builder
+NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making
+ Android application like DoliDroid able to provide native features for multicompany module.
+
+For developers:
+* Code changes to be more compatible with PSR2
+* Removed trigger USER_LOGOUT, USER_LOGIN, USER_LOGIN_FAILED (Some hooks are already dedicated for that)
+
+WARNING:
+
+Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
+* If you use some links like viewimages.php?modulepart=mycompany&file=... in you external modules, you must
+ replace them with links like viewimages.php?modulepart=mycompany&file=logos/... (note that link change only for
+ modulepart=mycompany that now works like others).
+
+
+
+***** ChangeLog for 8.0.1 compared to 8.0.0 *****
+FIX: #9258
+FIX: #9328
+FIX: #9337
+FIX: adding GROUP BY for PostgreSQL
+FIX: API template for list pages in module builder
+FIX: API template for record page to delete a record
+FIX: a removed option was still in setup
+FIX: badge on time spent on project and tasks
+FIX: Delete file on smartphone
+FIX: Fetch function will fetch comments
+FIX: Fetch task will now fetch comments
+FIX: $fk_account is always empty, must be $soc->fk_account
+FIX: Force stripe api version to avoid trouble if we update stripe api
+FIX: get_product_vat_for_country functions.lib.php
+FIX: Get templates in a forced language
+FIX: hook on dispatch order fourn
+FIX: Language selection lost if error during creation of email template
+FIX: Look and feel v8
+FIX: propal.class.php
+FIX: Add calls to fetchComments function
+FIX: Remove fetchComments from project and task fetch function
+FIX: remove internal property isextrafieldmanaged from API returns
+FIX: sql error
+FIX: table llx_chargessociales doesn't exists
+FIX: trans on null object
+FIX: vat rate code not returned by get_product_vat_for_country
+FIX: warning for late template invoices to remove when suspended
+FIX: Add hidden option MAIN_xxx_IN_SOURCE_ADDRESS to solve legal issues on PDF
+FIX: Table llx_facture_rec_extrafields missing after migration
+
+
+***** ChangeLog for 8.0.0 compared to 7.0.0 *****
+For Users:
+NEW: Experimental module: Ticket
+NEW: Experimental module: WebDAV
+NEW: Accept anonymous events (no user assigned)
+NEW: Accountancy - Add import on general ledger
+NEW: Accountancy - Show journal name on journal page and hide button draft export (Add an option in admin)
+NEW: Can create event from record card of a company and/or member
+NEW: Add a button to create Stripe customer from the customer Payment mode tab
+NEW: Add accounting account number on product tooltip
+NEW: Add any predefined mail content
+NEW: Add arrows to navigate into containers in experimental website module
+NEW: Add a tab to specify accountant/auditor of the company
+NEW: Add Date delivery and Availability on Propals List
+NEW: Add date in goods reception supplier order table
+NEW: Add delivery_time_days of suppliers in export profile
+NEW: Add Documents'tab to expedition module
+NEW: Use dol_print_phone in thirdparty list page to format phone
+NEW: Add entry for the GDPR contact
+NEW: Add extrafield type "html"
+NEW: Add file number in accountant card and update export filename
+NEW: Add files management on products lot
+NEW: add filter on project task list
+NEW: Add hidden option COMPANY_AQUARIUM_CLEAN_REGEX to clean generated
+NEW: add internal stripe payment page for invoice
+NEW: Add key __USER_REMOTE_IP__ into available substitution variables
+NEW: Add link between credit note invoice and origin
+NEW: Add linked file tab to vat
+NEW: add link to stripe's info in bank menu
+NEW: Add margin filters
+NEW: Add mass action enable/disable on cron job list
+NEW: Add mass action on project's list to close projects
+NEW: Add method to register distributed payments on invoices
+NEW: Add multicurrency support for product buy price for supplier propales, orders and invoices
+NEW: Add name of day in the timesheet input page per day.
+NEW: add new parameters for tcpf encryption
+NEW: add optional esign field in pdf propal
+NEW: Add option BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD
+NEW: Add option CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES
+NEW: Add param $dolibarr_main_restrict_ip in config file to limit ips
+NEW: add pdf function to check if pdf file is protected/encrypted
+NEW: Add pdf template for stock/warehouse module
+NEW: Add phone format for a lot of countries
+NEW: Add product and product categories filters on customer margins
+NEW: Add product categories filter on product margin
+NEW: Add romanian chart of accounts
+NEW: Add stats in salaries module
+NEW: add stripe transaction
+NEW: Add tab contact on supplier proposals
+NEW: Add total of time spent in timespent page at top of page too.
+NEW: Add trigger CONTRACT_MODIFY
+NEW: Add triggers on ECM object and add fill src_object_type/id fields
+NEW: Add type of website container/page into dictionary
+NEW: advance target filtering can be used everywhere with tpl and fk_element
+NEW: Allow negative quantity for dispatch (supplier order)
+NEW: bank reconcile: checkbox to select all bank operations
+NEW: Better performance with openldap
+NEW: Can add filter actiontype and notactiontype on event ical export
+NEW: Can add product in supplier order/invoice even w/o predefined price
+NEW: cancel orders on massaction
+NEW: Can crop image files attached in "document" tabs of a member
+NEW: Can delete dir content in media and ECM module recursively
+NEW: Can dispatch if more than ordered (if hidden option set)
+NEW: Can edit the text color for title line of tables
+NEW: Can enter time spent from the list of time spent of project
+NEW: Can export leave requests
+NEW: Can filter on account range in general ledger grouped by account
+NEW: Can filter on country and taxid into the binding page
+NEW: Can filter on progression in timesheet
+NEW: Can fix the bank account of a payment if payment not conciliated
+NEW: Can force usage of shared link for photo of products
+NEW: Can get template of email from its label
+NEW: Can see Unit Purchase Value of product in stock movement
+NEW: Can select from the user list into send form email (For field to and CC)
+NEW: Can select sample to use when creating a new page
+NEW: can send mail from project card
+NEW: Can set position of images in module tickets
+NEW: Can set the reply-to into email sent
+NEW: Can set the start/end date of service line in invoice templates
+NEW: Can share any file from the "Document" tab.
+NEW: Can sort on priority in task scheduler list
+NEW: Can sort order of files in attach tab for leave and expensereport
+NEW: Can use setValueFrom without user modification field
+NEW: Cat set the encryption algorithm for extrafields of type password
+NEW: check idprof1 for country pt
+NEW: default add action: new param $backurlforcard to redirect to card
+NEW: default warehouse field for products + prefill warehouses when dispatching supplier orders
+NEW: Display price HT on all commercial area boards
+NEW: display total on contract service list
+NEW: display weight volume in proposal
+NEW: Edit of extrafields position page on the edit form
+NEW: Experimental DAV module provides a public and private directory
+NEW: export filter models can be share or not by user
+NEW: Externalsite module can accept iframe content.
+NEW: Filter export model is now by user
+NEW: Finish implementation of option PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES
+NEW: generalize use of button to create new element from list
+NEW: hidden conf AGENDA_NB_WEEKS_IN_VIEW_PER_USER to set nb weeks to show into per user view
+NEW: hidden conf to assign category to thirparty that are neither customer nor prospect or supplier
+NEW: hidden conf to set nb weeks to show into user view
+NEW: hidden option MAIN_DISABLE_FREE_LINES
+NEW: improve way of adding users/sales representative to thirdparty
+NEW: Introduce option THIRDPARTY_QUICKSEARCH_ON_FIELDS to personalize fields use to search on quick search.
+NEW: Introduce permission "approve" for "leave request" like for "expense report"
+NEW: Load product data optional fields to the line -> enables to use "line_options_{extrafield}"
+NEW: Look and feel v8 - Show Picto "+" on all links "Add record"
+NEW: Look and feel v8: Use a different picto for delete and unlink
+NEW: mail templates for projects
+NEW: Module variant supported on services
+NEW: monthly VAT report show "Claimed for the period" + "Paid during this
+NEW: Mutualize code for action="update_extras"
+NEW: On invoice card, show accounting account linked
+NEW: Online payment of invoice and subscription record the payment
+NEW: OnSearchAndListGoOnCustomerOrSupplierCard conf
+NEW: Optimize load of hooks classes (save 1-5Kb of memory)
+NEW: Option MAIN_SHOW_REGION_IN_STATE renamed into MAIN_SHOW_REGION_IN_STATE_SELECT are more complete
+NEW: Option to force all emails recipient
+NEW: Hidden option to send to salaries into emails forms
+NEW: order minimum amount
+NEW: add price in burger menu on mouvement list
+NEW: Report a list of leave requests for a month
+NEW: Section of files generated by mass action not visible if empty
+NEW: send mails from project card
+NEW: Show also size in bytes in tooltip if visible unit is not bytes
+NEW: Show keyboard shortcut of nav arrow into tooltip
+NEW: Show last result code of cron jobs in error in red
+NEW: Show region in company info & Global option to show state code MAIN_SHOW_STATE_CODE
+NEW: Show total number of records by category
+NEW: Show total of time consumed in week in time spent entry page
+NEW: Stripe online payments reuse the same stripe customer account
+NEW: Suggest link to pay online for customer orders
+NEW: supplier credit notes is now supported like for customer credit notes
+NEW: supplier order/order lines export: add supplier product ref
+NEW: supplier relative discounts
+NEW: Support alternative aliases of page name in website
+NEW: syslog file autoclean
+NEW: thirdparty categ filter on lists
+NEW: Use a css style for weekend in time spent
+NEW: Use common substitution rule for language to get translation in ODT
+NEW: Variable __ONLINE_PAYMENT_URL__ available in email templates
+
+For developers:
+NEW: class reposition can also work on POST (not only GET)
+NEW: add a hook in dol_print_phone
+NEW: The field "visible" on extrafield can accept expression as condition
+NEW: Upgrade of Stripe lib to 6.4.1
+NEW: work on CommonObject 'array' field typeNew common object array
+NEW: method Form::selectArrayFilter() + use in left menu search
+NEW: [REST API] Add the possibility to remove a category from a thirdparty
+NEW: doActions on categorycard
+NEW: add "moreHtmlRef" hook
+NEW: add hook for more permissions control
+NEW: add hook moreHtmlStatus to complete to status on banners
+NEW: Add hook printEmail
+NEW: Add hook setContentSecurityPolicy
+NEW: Add password_hash as a hash algorithm
+NEW: Add dol_is_link function
+NEW: Adds a contact to an invoice with REST API
+NEW: Adds a payment for the list of invoices given as parameter
+NEW: adds billing contacts ids to REST API returns
+NEW: Add showempty parameter in country selection
+NEW: add printUserListWhere hook
+NEW: add "printUserPasswordField" hooks
+NEW: Call to trigger on payment social contribution creation
+NEW: Call to trigger on social contribution creation
+NEW: hook getnomurltooltip is replaced with hook getNomUrl more powerfull
+
+WARNING:
+
+Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
+* Remove old deprecated hook 'insertExtraFields'. Triggers must be used for action on CRUD events.
+* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from
+ 'doaction' into 'sendMail'.
+* Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and
+ CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE
+* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is
+ a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required.
+* PHP 5.3 is no more supported. Minimum PHP is now 5.4+
+* Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are
+ already available and are better.
+* Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better.
+* The hook contaxt commcard has been renamed thirdpartycomm
+* The hook contaxt thirdpartycard has been renamed thirdpartycontact
+* Remove method Categorie:get_nb_categories() that was not used.
+* Hook getnomurltooltip provide a duplicate feature compared to hook getNomUrl so all hooks getnomurltooltip
+ are now replaced with hook getNomUrl.
+* The substitution key __CONTACTCIVNAME__ is no longer present, it has been replaced by __CONTACT_NAME_{TYPE}__
+ where {TYPE} is contact type code (BILLING, SHIPPING, CUSTOMER, ... see contact type dictionnary).
+
+
***** ChangeLog for 7.0.3 compared to 7.0.2 *****
FIX: 7.0 task contact card without withproject parameters
FIX: #8722
@@ -40,29 +284,6 @@ FIX: supplier order: product supplier ref not saved on addline
FIX: test is_erasable() must be done before call function delete() too to avoid delete invoice with &action=delete in url
FIX: wrong var name $search_month_lim
-***** ChangeLog for 8.0.0 compared to 7.0.0 *****
-
-WARNING:
-
-Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
-* Remove old deprecated hook 'insertExtraFields'. Triggers must be used for action on CRUD events.
-* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from
- 'doaction' into 'sendMail'.
-* Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and
- CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE
-* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is
- a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required.
-* PHP 5.3 is no more supported. Minimum PHP is now 5.4+
-* Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are
- already available and are better.
-* Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better.
-* The hook contaxt commcard has been renamed thirdpartycomm
-* The hook contaxt thirdpartycard has been renamed thirdpartycontact
-* Remove method Categorie:get_nb_categories() that was not used.
-* Hook getnomurltooltip provide a duplicate feature compared to hook getNomUrl so all hooks getnomurltooltip
- are now replaced with hook getNomUrl.
-
-
***** ChangeLog for 7.0.2 compared to 7.0.1 *****
FIX: #8023
FIX: #8259 can't update contact birthday with REST API
@@ -220,7 +441,7 @@ FIX: Use of undefined constant _ROWS_2
FIX: warning when adding ECM files using old photo path
-***** ChangeLog for 7.0.0 compared to 6.0.5 *****
+***** ChangeLog for 7.0.0 compared to 6.0.7 *****
For users:
NEW: Add a preview icon after files that can be previewed (pdf + images)
NEW: When payment is registered, PDF of invoices are also regenerated so payments
diff --git a/README.md b/README.md
index b68e8b65558..dfd9d70ab7c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,10 @@
# DOLIBARR ERP & CRM
- 
+
+
+|6|7|8|develop|
+|----------|----------|----------|----------|
+|||||
Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…).
diff --git a/build/aps/Limitations of APS Support in the Panel_fichiers/highlight.js b/build/aps/Limitations of APS Support in the Panel_fichiers/highlight.js
index d6386c93792..10056e95fd4 100644
--- a/build/aps/Limitations of APS Support in the Panel_fichiers/highlight.js
+++ b/build/aps/Limitations of APS Support in the Panel_fichiers/highlight.js
@@ -15,14 +15,14 @@ else return 0;
function highlightTOC(str) {
-
-
-
-
-
+
+
+
+
+
if (StopProcess()) return;
try {
-
+
str = str || parent.BODY.document.location.href;
uri = last(str);
list = parent.TOC.document.getElementsByTagName("a");
@@ -33,7 +33,7 @@ function highlightTOC(str) {
list[i].style.backgroundColor = "#6697cc";
list[i].style.padding = "2px";
list[i].style.color = "#ffffff";
-
+
} else {
list[i].style.backgroundColor = "#ffffff";
list[i].style.color = "#003380";
diff --git a/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.css b/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.css
index ee31b50285a..ab64ac4bb6b 100644
--- a/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.css
+++ b/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.css
@@ -12,7 +12,7 @@
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
-pre.preformatted {
+pre.preformatted {
display: block;
font-family: "Courier New", verdana, arial, helvetica, sans-serif;
diff --git a/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.js b/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.js
index 11234738656..fab5c8e6f2a 100644
--- a/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.js
+++ b/build/aps/Limitations of APS Support in the Panel_fichiers/prettify.js
@@ -1116,7 +1116,7 @@ window['_pr_isIE6'] = function () {
for (var i = 0; i < 10; ++i) {
lineBreaks[i] = lineBreakHtml + '';
}
- var lineNum = numberLines[1] && numberLines[1].length
+ var lineNum = numberLines[1] && numberLines[1].length
? numberLines[1] - 1 : 0; // Lines are 1-indexed
html.push('>%{name}.lang
%_datadir/dolibarr/htdocs/supplier_proposal
%_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme
+%_datadir/dolibarr/htdocs/ticket
%_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices
diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec
index 2fed89c03f3..673d5919d1a 100755
--- a/build/rpm/dolibarr_generic.spec
+++ b/build/rpm/dolibarr_generic.spec
@@ -292,6 +292,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/supplier_proposal
%_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme
+%_datadir/dolibarr/htdocs/ticket
%_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices
diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec
index fb15a2d2d92..e3d2a849db2 100755
--- a/build/rpm/dolibarr_mandriva.spec
+++ b/build/rpm/dolibarr_mandriva.spec
@@ -209,6 +209,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/supplier_proposal
%_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme
+%_datadir/dolibarr/htdocs/ticket
%_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices
diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec
index 70eba841bd8..5a64bec2e78 100755
--- a/build/rpm/dolibarr_opensuse.spec
+++ b/build/rpm/dolibarr_opensuse.spec
@@ -220,6 +220,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/supplier_proposal
%_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme
+%_datadir/dolibarr/htdocs/ticket
%_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices
diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt
index cdbc2e2bb40..6303eaafaae 100644
--- a/dev/dolibarr_changes.txt
+++ b/dev/dolibarr_changes.txt
@@ -48,6 +48,23 @@ into
// initialize subsetchars
$subsetchars = array_fill(0, 256, true);
+* Replace the continue into switch with a break:
+
+case 're': {
+ // justify block
+ if (!TCPDF_STATIC::empty_string($this->lispacer)) {
+ $this->lispacer = '';
+ continue;
+ }
+
+into
+case 're': {
+ // justify block
+ if (!TCPDF_STATIC::empty_string($this->lispacer)) {
+ $this->lispacer = '';
+ break;
+ }
+
* Optionnaly, removed all fonts except
dejavusans* (used by greek, arab, persan, romanian, turkish),
freemono* (russian),
diff --git a/dev/examples/code/create_invoice.php b/dev/examples/code/create_invoice.php
index bd82d38d306..e519c62a436 100755
--- a/dev/examples/code/create_invoice.php
+++ b/dev/examples/code/create_invoice.php
@@ -40,7 +40,7 @@ $error=0;
// -------------------- START OF YOUR CODE HERE --------------------
// Include Dolibarr environment
-require_once($path."../../htdocs/master.inc.php");
+require_once $path."../../htdocs/master.inc.php";
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
//$langs->setDefaultLang('en_US'); // To change default language of $langs
@@ -58,7 +58,7 @@ print "***** ".$script_file." (".$version.") *****\n";
// Start of transaction
$db->begin();
-require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
+require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
// Create invoice object
$obj = new Facture($db);
diff --git a/dev/examples/code/create_order.php b/dev/examples/code/create_order.php
index 4575e9e28f3..95b047705fa 100755
--- a/dev/examples/code/create_order.php
+++ b/dev/examples/code/create_order.php
@@ -40,7 +40,7 @@ $error=0;
// -------------------- START OF YOUR CODE HERE --------------------
// Include Dolibarr environment
-require_once($path."../../htdocs/master.inc.php");
+require_once $path."../../htdocs/master.inc.php";
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
//$langs->setDefaultLang('en_US'); // To change default language of $langs
@@ -59,7 +59,7 @@ print "***** ".$script_file." (".$version.") *****\n";
// Start of transaction
$db->begin();
-require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
+require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
// Create order object
$com = new Commande($db);
diff --git a/dev/examples/code/create_product.php b/dev/examples/code/create_product.php
index 61598ff59d9..8cbc07a1b63 100755
--- a/dev/examples/code/create_product.php
+++ b/dev/examples/code/create_product.php
@@ -40,7 +40,7 @@ $error=0;
// -------------------- START OF YOUR CODE HERE --------------------
// Include Dolibarr environment
-require_once($path."../../htdocs/master.inc.php");
+require_once $path."../../htdocs/master.inc.php";
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
//$langs->setDefaultLang('en_US'); // To change default language of $langs
@@ -59,7 +59,7 @@ print "***** ".$script_file." (".$version.") *****\n";
// Start of transaction
$db->begin();
-require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
+require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
// Create instance of object
$myproduct=new Product($db);
diff --git a/dev/examples/code/create_user.php b/dev/examples/code/create_user.php
index 20173eb914a..f8e0ba23011 100755
--- a/dev/examples/code/create_user.php
+++ b/dev/examples/code/create_user.php
@@ -40,7 +40,7 @@ $error=0;
// -------------------- START OF YOUR CODE HERE --------------------
// Include Dolibarr environment
-require_once($path."../../htdocs/master.inc.php");
+require_once $path."../../htdocs/master.inc.php";
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
//$langs->setDefaultLang('en_US'); // To change default language of $langs
@@ -58,7 +58,7 @@ print "***** ".$script_file." (".$version.") *****\n";
// Start of transaction
$db->begin();
-require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
+require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php";
// Create user object
$obj = new User($db);
diff --git a/dev/examples/code/get_contracts.php b/dev/examples/code/get_contracts.php
index fbe512300e8..daff0e43e6f 100755
--- a/dev/examples/code/get_contracts.php
+++ b/dev/examples/code/get_contracts.php
@@ -40,7 +40,7 @@ $error=0;
// -------------------- START OF YOUR CODE HERE --------------------
// Include Dolibarr environment
-require_once($path."../../htdocs/master.inc.php");
+require_once $path."../../htdocs/master.inc.php";
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
//$langs->setDefaultLang('en_US'); // To change default language of $langs
@@ -65,7 +65,7 @@ print 'Argument id_thirdparty='.$argv[1]."\n";
// Start of transaction
$db->begin();
-require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
+require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
// Create contract object
$obj = new Contrat($db);
diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php
index e313aa44d1f..4064336cbab 100755
--- a/dev/initdata/generate-invoice.php
+++ b/dev/initdata/generate-invoice.php
@@ -32,9 +32,9 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
//$path=preg_replace('/generate-produit.php/i','',$_SERVER["PHP_SELF"]);
-require (__DIR__. '/../../htdocs/master.inc.php');
-require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
-require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+require __DIR__. '/../../htdocs/master.inc.php';
+require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
+require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
/*
diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php
index c73b15b620d..5e53fa752a2 100755
--- a/dev/initdata/generate-order.php
+++ b/dev/initdata/generate-order.php
@@ -33,14 +33,14 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
//$path=preg_replace('/generate-commande.php/i','',$_SERVER["PHP_SELF"]);
-require (__DIR__. '/../../htdocs/master.inc.php');
+require __DIR__. '/../../htdocs/master.inc.php';
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
-require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
+require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
/*
diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php
index 3ae44b00b3a..393d5c5ce3d 100755
--- a/dev/initdata/generate-product.php
+++ b/dev/initdata/generate-product.php
@@ -33,7 +33,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
//$path=preg_replace('/generate-produit.php/i','',$_SERVER["PHP_SELF"]);
-require (__DIR__. '/../../htdocs/master.inc.php');
+require __DIR__. '/../../htdocs/master.inc.php';
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php
index 6f1dc293a68..631b734fc9e 100755
--- a/dev/initdata/generate-proposal.php
+++ b/dev/initdata/generate-proposal.php
@@ -33,11 +33,11 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
//$path=preg_replace('/generate-propale.php/i','',$_SERVER["PHP_SELF"]);
-require (__DIR__. '/../../htdocs/master.inc.php');
-require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
-require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
-require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
-require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+require __DIR__. '/../../htdocs/master.inc.php';
+require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
+require_once DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php";
+require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
+require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
/*
* Parameters
@@ -157,7 +157,7 @@ $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"))
{
- require_once(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;
diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php
index 992ab61f4ef..7f2c3e2055d 100755
--- a/dev/initdata/generate-thirdparty.php
+++ b/dev/initdata/generate-thirdparty.php
@@ -33,7 +33,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
//$path=preg_replace('/generate-societe.php/i','',$_SERVER["PHP_SELF"]);
-require (__DIR__. '/../../htdocs/master.inc.php');
+require __DIR__. '/../../htdocs/master.inc.php';
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
diff --git a/dev/initdata/import-products.php b/dev/initdata/import-products.php
index a08e3b6066e..0f4856aefb2 100755
--- a/dev/initdata/import-products.php
+++ b/dev/initdata/import-products.php
@@ -21,7 +21,7 @@
/**
* \file dev/initdata/import-product.php
- * \brief Script example to insert products from a csv file.
+ * \brief Script example to insert products from a csv file.
* To purge data, you can have a look at purge-data.php
*/
@@ -36,7 +36,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
$path=preg_replace('/import-products.php/i','',$_SERVER["PHP_SELF"]);
-require ($path."../../htdocs/master.inc.php");
+require $path."../../htdocs/master.inc.php";
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@@ -118,22 +118,22 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{
$i++;
$errorrecord=0;
-
+
if ($startlinenb && $i < $startlinenb) continue;
if ($endlinenb && $i > $endlinenb) continue;
-
+
$nboflines++;
-
+
$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->volume_unit = 0;
$produit->weight = price2num($fields[9]);
$produit->weight_units = 0; // -3 = g
@@ -142,9 +142,9 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
$produit->status = 1;
$produit->status_buy = 1;
-
+
$produit->finished = 1;
-
+
$produit->price_min = null;
$produit->price_min_ttc = null;
$produit->price = price2num($fields[11]);
@@ -152,25 +152,25 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
$produit->price_base_type = 'TTC';
$produit->tva_tx = price2num($fields[13]);
$produit->tva_npr = 0;
-
+
$produit->cost_price = price2num($fields[16]);
-
+
// 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
+ 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)
{
@@ -181,14 +181,14 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
$errorrecord++;
}
- else
+ else
{
print " - updatePrice OK";
}
}
-
+
dol_syslog("Add multilangs");
-
+
// Add alternative languages
if (! $errorrecord && 1)
{
@@ -201,15 +201,15 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
$errorrecord++;
}
- else
+ else
{
print " - setMultiLangs OK";
}
}
-
+
print "\n";
-
- if ($errorrecord)
+
+ if ($errorrecord)
{
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
$error++; // $errorrecord will be reset
diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php
index 0c32c7ea6a3..63c6856e5ec 100755
--- a/dev/initdata/import-thirdparties.php
+++ b/dev/initdata/import-thirdparties.php
@@ -36,7 +36,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
$path=preg_replace('/import-thirdparties.php/i','',$_SERVER["PHP_SELF"]);
-require ($path."../../htdocs/master.inc.php");
+require $path."../../htdocs/master.inc.php";
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
diff --git a/dev/initdata/import-users.php b/dev/initdata/import-users.php
index 3aaa9c11a4a..c94f74341f6 100755
--- a/dev/initdata/import-users.php
+++ b/dev/initdata/import-users.php
@@ -21,7 +21,7 @@
/**
* \file dev/initdata/import-thirdparties.php
- * \brief Script example to insert thirdparties from a csv file.
+ * \brief Script example to insert thirdparties from a csv file.
* To purge data, you can have a look at purge-data.php
*/
@@ -36,7 +36,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
$path=preg_replace('/import-users.php/i','',$_SERVER["PHP_SELF"]);
-require ($path."../../htdocs/master.inc.php");
+require $path."../../htdocs/master.inc.php";
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@@ -118,15 +118,15 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{
$i++;
$errorrecord=0;
-
+
if ($startlinenb && $i < $startlinenb) continue;
if ($endlinenb && $i > $endlinenb) continue;
-
+
$nboflines++;
-
+
$object = new User($db);
$object->statut = 1;
-
+
$tmp=explode(' ',$fields[3],2);
$object->firstname = trim($tmp[0]);
$object->lastname = trim($tmp[1]);
@@ -134,23 +134,23 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
else $object->login=strtolower($object->firstname);
$object->login=preg_replace('/ /','',$object->login);
$object->password = 'init';
-
+
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
+ else
{
print " - Creation OK with login ".$object->login." - id = ".$ret;
}
print "\n";
-
- if ($errorrecord)
+
+ if ($errorrecord)
{
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
$error++; // $errorrecord will be reset
diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php
index f992dcb2dc6..5a1e7b3afc3 100755
--- a/dev/initdata/purge-data.php
+++ b/dev/initdata/purge-data.php
@@ -36,7 +36,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Recupere root dolibarr
$path=preg_replace('/purge-data.php/i','',$_SERVER["PHP_SELF"]);
-require ($path."../../htdocs/master.inc.php");
+require $path."../../htdocs/master.inc.php";
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
diff --git a/dev/initdemo/sftpget_and_loaddump.php b/dev/initdemo/sftpget_and_loaddump.php
index 981ff964b8e..98cb6189935 100755
--- a/dev/initdemo/sftpget_and_loaddump.php
+++ b/dev/initdemo/sftpget_and_loaddump.php
@@ -41,15 +41,15 @@ $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 && 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');
+include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
/*
diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php
index 9c453096904..53717314d5f 100755
--- a/dev/initdemo/updatedemo.php
+++ b/dev/initdemo/updatedemo.php
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
* or see http://www.gnu.org/
- *
+ *
* Get a distant dump file and load it into a mysql database
*/
@@ -36,15 +36,15 @@ $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 && 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');
+include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
/*
@@ -74,7 +74,7 @@ $tables=array(
$year=2010;
$currentyear=$tmp['year'];
-while ($year <= $currentyear)
+while ($year <= $currentyear)
{
//$year=2021;
$delta=($currentyear - $year);
@@ -84,7 +84,7 @@ while ($year <= $currentyear)
{
foreach($tables as $tablekey => $tableval)
{
- print "\nCorrect ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
+ print "\nCorrect ".$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);
@@ -110,14 +110,14 @@ while ($year <= $currentyear)
//print $sql2."\n";
$resql2 = $db->query($sql2);
if (! $resql2) dol_print_error($db);
- }
+ }
$i++;
}
}
else dol_print_error($db);
}
}
-
+
$year++;
}
diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml
index a43e4dde82b..79b16bdbf55 100644
--- a/dev/setup/codesniffer/ruleset.xml
+++ b/dev/setup/codesniffer/ruleset.xml
@@ -4,6 +4,7 @@
Dolibarr coding standard.
build/html
+ build/aps
documents
htdocs/custom
htdocs/includes
@@ -11,43 +12,29 @@
*/nltechno*
*/htdocs/includes
*.min.css
+ *.js
-
+
-
+
0
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
- 0
-
-
- 0
-
+
+
+
+
+
+
+
+
+
+
+
@@ -147,7 +134,7 @@
0
-
+
@@ -163,7 +150,7 @@
0
-
+
@@ -171,7 +158,23 @@
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
@@ -186,7 +189,7 @@
0
-
+
0
@@ -206,14 +209,14 @@
0
-
+
0
-
-
-
-
+
5
-
-
+
+
+
+
@@ -254,11 +257,11 @@
0
-
+
0
-
+
0
@@ -285,7 +288,20 @@
-
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
@@ -315,14 +331,14 @@
0
-
+
0
-
+
0
@@ -330,7 +346,7 @@
0
-
+
@@ -347,31 +363,37 @@
0
-
+
+
0
+
+
+
0
-
+
-
+
diff --git a/dev/tools/test/testtcpdf.php b/dev/tools/test/testtcpdf.php
index e14dae9c2a3..ce962dce3d9 100755
--- a/dev/tools/test/testtcpdf.php
+++ b/dev/tools/test/testtcpdf.php
@@ -27,8 +27,8 @@
* @since 2008-03-04
*/
-require_once('../../htdocs/includes/tecnickcom/tcpdf/config/tcpdf_config.php');
-require_once('../../htdocs/includes/tecnickcom/tcpdf/tcpdf.php');
+require_once '../../htdocs/includes/tecnickcom/tcpdf/config/tcpdf_config.php';
+require_once '../../htdocs/includes/tecnickcom/tcpdf/tcpdf.php';
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
diff --git a/dev/tools/test/testutf.php b/dev/tools/test/testutf.php
index c626a92a57d..ffa746bcab5 100644
--- a/dev/tools/test/testutf.php
+++ b/dev/tools/test/testutf.php
@@ -47,8 +47,8 @@ print 'Files has been created. Check its name from your explorer'."\n";
* @since 2008-09-15
*/
-require_once('../../htdocs/includes/tecnickcom/tcpdf/config/tcpdf_config.php');
-require_once('../../htdocs/includes/tecnickcom/tcpdf/tcpdf.php');
+require_once '../../htdocs/includes/tecnickcom/tcpdf/config/tcpdf_config.php';
+require_once '../../htdocs/includes/tecnickcom/tcpdf/tcpdf.php';
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php
index 47d6a25ec15..123b7f6157d 100644
--- a/dev/translation/autotranslator.class.php
+++ b/dev/translation/autotranslator.class.php
@@ -64,8 +64,7 @@ class autoTranslator
// Translate
//ini_set('default_charset','UTF-8');
ini_set('default_charset',$this->_outputpagecode);
- $this->parse_refLangTranslationFiles();
-
+ $this->parseRefLangTranslationFiles();
}
/**
@@ -73,7 +72,7 @@ class autoTranslator
*
* @return void
*/
- private function parse_refLangTranslationFiles()
+ private function parseRefLangTranslationFiles()
{
$files = $this->getTranslationFilesArray($this->_refLang);
@@ -346,5 +345,4 @@ class autoTranslator
return $rep;
}
-
}
diff --git a/dev/translation/autotranslator.php b/dev/translation/autotranslator.php
index 58314a23b9e..c7897810a72 100755
--- a/dev/translation/autotranslator.php
+++ b/dev/translation/autotranslator.php
@@ -37,8 +37,8 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
}
// Include Dolibarr environment
-require_once($path.'../../htdocs/master.inc.php');
-require_once($path.'../../htdocs/core/lib/files.lib.php');
+require_once $path.'../../htdocs/master.inc.php';
+require_once $path.'../../htdocs/core/lib/files.lib.php';
// After this $db is an opened handler to database. We close it at end of file.
// Load main language strings
@@ -88,7 +88,7 @@ if ($argv[2] != 'all')
}
}
-require_once(DOL_DOCUMENT_ROOT."/../dev/translation/autotranslator.class.php");
+require_once DOL_DOCUMENT_ROOT."/../dev/translation/autotranslator.class.php";
$langParser = new autoTranslator($argv[2],$argv[1],$dir,$file,$argv[3]);
diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php
index f65cefd7f94..2eedcda8760 100755
--- a/dev/translation/sanity_check_en_langfiles.php
+++ b/dev/translation/sanity_check_en_langfiles.php
@@ -295,6 +295,9 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a
if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
if (preg_match('/^ModuleCompanyCode/', $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;
diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index 493c9e62717..ca47dbc7b96 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -121,6 +121,9 @@ if (empty($reshook))
if ($country_code)
{
$sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql';
+
+ // FIXME Get the ADD rowid and pass it + num of comapny * 100 000 000 to run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value.
+
$result = run_sql($sqlfile, 1, 0, 1);
}
@@ -406,5 +409,6 @@ if ($resql)
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php
index f024f54c41c..2c7d92f3735 100644
--- a/htdocs/accountancy/admin/accountmodel.php
+++ b/htdocs/accountancy/admin/accountmodel.php
@@ -1004,7 +1004,7 @@ if ($id)
print ' ';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index 9643227da64..6a92a3f6080 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -397,6 +397,6 @@ else if ($id > 0 || $ref) {
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php
index aec34469559..735c5595ddc 100644
--- a/htdocs/accountancy/admin/categories.php
+++ b/htdocs/accountancy/admin/categories.php
@@ -184,6 +184,6 @@ if ($action == 'display' || $action == 'delete') {
print "";
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php
index 15a50e7b8e8..900205b7588 100644
--- a/htdocs/accountancy/admin/categories_list.php
+++ b/htdocs/accountancy/admin/categories_list.php
@@ -800,7 +800,7 @@ if ($id)
print ' ';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php
index c33d4326836..8cd45c1cfda 100644
--- a/htdocs/accountancy/admin/defaultaccounts.php
+++ b/htdocs/accountancy/admin/defaultaccounts.php
@@ -190,5 +190,6 @@ print 'trans("Error"), null, 'errors');
@@ -142,27 +142,27 @@ print ' {'."\n";
foreach ($listparam as $key => $param) {
print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
print ' {'."\n";
- print ' //console.log("'.$param[label].'");'."\n";
- if (empty($param[ACCOUNTING_EXPORT_FORMAT])) {
+ print ' //console.log("'.$param['label'].'");'."\n";
+ if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
} else {
- print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param[ACCOUNTING_EXPORT_FORMAT].'");'."\n";
+ print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
}
- if (empty($param[ACCOUNTING_EXPORT_SEPARATORCSV])) {
+ if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
} else {
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
}
- if (empty($param[ACCOUNTING_EXPORT_ENDLINE])) {
+ if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
} else {
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
}
- if (empty($param[ACCOUNTING_EXPORT_DATE])) {
+ if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
} else {
@@ -257,15 +257,15 @@ if ($num2) {
print '
';
// Param
- $label = $key[label];
+ $label = $key['label'];
print '' . $langs->trans($label) . ' ';
// Value
print '';
- if (is_array($key[param])) {
- print $form->selectarray($label, $key[param], $conf->global->$label, 0);
+ if (is_array($key['param'])) {
+ print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
} else {
- print ' ';
+ print ' ';
}
print ' ';
@@ -278,5 +278,6 @@ print '
' . $langs->trans("DateStart") . '
';
- print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear');
+ print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear');
print ' ';
// Date end
print '' . $langs->trans("DateEnd") . ' ';
- print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend');
+ print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend');
print ' ';
/*
@@ -225,12 +226,12 @@ if ($action == 'create')
// Date start
print '' . $langs->trans("DateStart") . ' ';
- print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear');
+ print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear');
print ' ';
// Date end
print '' . $langs->trans("DateEnd") . ' ';
- print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
+ print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
print ' ';
// Statut
@@ -318,5 +319,6 @@ if ($action == 'create')
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php
index f16e3b9ca0e..3141a624194 100644
--- a/htdocs/accountancy/admin/fiscalyear_info.php
+++ b/htdocs/accountancy/admin/fiscalyear_info.php
@@ -58,5 +58,6 @@ if ($id) {
print '';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php
index 3af46eec1a4..752e1c18de9 100644
--- a/htdocs/accountancy/admin/importaccounts.php
+++ b/htdocs/accountancy/admin/importaccounts.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2013-2017 Alexandre Spangaro
+ * Copyright (C) 2013-2017 Alexandre Spangaro
* Copyright (C) 2014 Florian Henry
*
* This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
*/
/**
- * \file htdocs/accountancy/admin/importaccounts.php
+ * \file htdocs/accountancy/admin/importaccounts.php
* \ingroup Advanced accountancy
* \brief Page import accounting account
*/
@@ -83,7 +83,7 @@ if ($_POST["action"] == 'import') {
$accounting->pcg_type = $monType;
$accounting->pcg_subtype = $monSubType;
$accounting->active = 1;
-
+
$result = $accounting->create($user);
if ($result > 0) {
setEventMessages($langs->trans("AccountingAccountAdd"), null, 'mesgs');
@@ -101,7 +101,7 @@ if ($_POST["action"] == 'import') {
print '' . $langs->trans("EndProcessing") . '
';
}
-// list accounting account from product
+// list accounting account from product
$sql = "(SELECT p.rowid as product_id, p.accountancy_code_sell as accounting ";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
@@ -172,14 +172,15 @@ if ($result) {
print '';
$i ++;
}
-
+
print ' ';
-
+
print '';
print '';
} else {
print $db->error();
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index e39d07fc35d..a17ee45ae4d 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -295,5 +295,6 @@ print ' ';
print ' ';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php
index ff3a38769b8..20d0a5200a5 100644
--- a/htdocs/accountancy/admin/journals_list.php
+++ b/htdocs/accountancy/admin/journals_list.php
@@ -128,16 +128,16 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
- // Must match ids defined into eldy.lib.php
- $sourceList = array(
- '1' => $langs->trans('AccountingJournalType1'),
- '2' => $langs->trans('AccountingJournalType2'),
- '3' => $langs->trans('AccountingJournalType3'),
- '4' => $langs->trans('AccountingJournalType4'),
- '5' => $langs->trans('AccountingJournalType5'),
- '8' => $langs->trans('AccountingJournalType8'),
- '9' => $langs->trans('AccountingJournalType9')
- );
+// Must match ids defined into eldy.lib.php
+$sourceList = array(
+ '1' => $langs->trans('AccountingJournalType1'),
+ '2' => $langs->trans('AccountingJournalType2'),
+ '3' => $langs->trans('AccountingJournalType3'),
+ '4' => $langs->trans('AccountingJournalType4'),
+ '5' => $langs->trans('AccountingJournalType5'),
+ '8' => $langs->trans('AccountingJournalType8'),
+ '9' => $langs->trans('AccountingJournalType9'),
+);
/*
* Actions
@@ -294,10 +294,10 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
-if (GETPOST('actioncancel'))
-{
- //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
-}
+//if (GETPOST('actioncancel'))
+//{
+// $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
+//}
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
@@ -683,7 +683,7 @@ if ($id)
print ' ';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index 070e2f353c3..2467b89b108 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -495,5 +495,6 @@ if ($result)
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index 284ead4fb56..e3290f1e542 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2016 Florian Henry
- * Copyright (C) 2016-2018 Alexandre Spangaro
+/* Copyright (C) 2016 Olivier Geffroy
+ * Copyright (C) 2016 Florian Henry
+ * Copyright (C) 2016-2018 Alexandre Spangaro
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -193,9 +194,9 @@ else {
$moreforfilter .= '';
$moreforfilter .= $langs->trans('DateStart') . ': ';
- $moreforfilter .= $form->select_date($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0, 1);
+ $moreforfilter .= $form->selectDate($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateEnd') . ': ';
- $moreforfilter .= $form->select_date($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0, 1);
+ $moreforfilter .= $form->selectDate($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= '
';
if (! empty($moreforfilter)) {
@@ -298,7 +299,8 @@ else {
print "";
print '';
- llxFooter();
}
+// End of page
+llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php
index 03265e434f6..3a0a1f73308 100644
--- a/htdocs/accountancy/bookkeeping/balancebymonth.php
+++ b/htdocs/accountancy/bookkeeping/balancebymonth.php
@@ -140,5 +140,6 @@ if ($resql) {
}
print "\n";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 92c5713880c..5add04d7361 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -3,6 +3,7 @@
* Copyright (C) 2013-2017 Florian Henry
* Copyright (C) 2013-2018 Alexandre Spangaro
* Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -350,7 +351,7 @@ if ($action == 'create')
print '';
print '' . $langs->trans("Docdate") . ' ';
print '';
- print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
+ print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print ' ';
print ' ';
@@ -432,7 +433,7 @@ if ($action == 'create')
print ' ';
print ' ';
print ' ';
- $form->select_date($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
+ print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print ' ';
print '';
} else {
@@ -714,5 +715,6 @@ if ($action == 'create')
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index b0a91f7ce36..132aa4e0afa 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -3,6 +3,7 @@
* Copyright (C) 2013-2016 Florian Henry
* Copyright (C) 2013-2017 Alexandre Spangaro
* Copyright (C) 2016-2017 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -465,11 +466,11 @@ if (! empty($arrayfields['t.doc_date']['checked']))
print '';
print '';
print $langs->trans('From') . ' ';
- print $form->select_date($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
+ print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
print '
';
print '';
print $langs->trans('to') . ' ';
- print $form->select_date($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
+ print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
print '
';
print ' ';
}
@@ -556,11 +557,11 @@ if (! empty($arrayfields['t.date_creation']['checked']))
print '';
print '';
print $langs->trans('From') . ' ';
- print $form->select_date($search_date_creation_start, 'date_creation_start', 0, 0, 1);
+ print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1);
print '
';
print '';
print $langs->trans('to') . ' ';
- print $form->select_date($search_date_creation_end, 'date_creation_end', 0, 0, 1);
+ print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1);
print '
';
print ' ';
}
@@ -570,11 +571,11 @@ if (! empty($arrayfields['t.tms']['checked']))
print '';
print '';
print $langs->trans('From') . ' ';
- print $form->select_date($search_date_modification_start, 'date_modification_start', 0, 0, 1);
+ print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1);
print '
';
print '';
print $langs->trans('to') . ' ';
- print $form->select_date($search_date_modification_end, 'date_modification_end', 0, 0, 1);
+ print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1);
print '
';
print ' ';
}
@@ -748,6 +749,6 @@ print ' ';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index 80a4f0db5e8..c5726901e2e 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -3,6 +3,7 @@
* Copyright (C) 2013-2016 Olivier Geffroy
* Copyright (C) 2013-2016 Florian Henry
* Copyright (C) 2013-2018 Alexandre Spangaro
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -287,10 +288,10 @@ print '';
print ' ';
print '';
print $langs->trans('From') . ': ';
-print $form->select_date($search_date_start, 'search_date_start', 0, 0, 1);
+print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1);
print ' ';
print $langs->trans('to') . ': ';
-print $form->select_date($search_date_end, 'search_date_end', 0, 0, 1);
+print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1);
print ' ';
print ' ';
print ' ';
@@ -421,5 +422,6 @@ print '';
print "";
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
index 9bf287bf3c9..be335107839 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville
* Copyright (C) 2005 Laurent Destailleur
* Copyright (C) 2013 Olivier Geffroy
- * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Florian Henry
* Copyright (C) 2013 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@
*/
/**
- * \file accounting/bookkeeping/thirdparty_lettrage.php
+ * \file accountancy/bookkeeping/thirdparty_lettrage.php
* \ingroup Advanced accountancy
* \brief Onglet de gestion de parametrages des ventilations
*/
@@ -82,8 +82,9 @@ $socid = GETPOST("socid", 'int');
$object = new Societe($db);
$object->id = $socid;
$result = $object->fetch($socid);
-if ($result < 0) {
- setEventMessage($object->error, 'errors');
+if ($result < 0)
+{
+ setEventMessages($object->error, $object->errors, 'errors');
}
$form = new Form($db);
@@ -252,7 +253,6 @@ if ($resql) {
print '';
print '';
- $var = false;
$solde = 0;
$tmp = '';
while ( $obj = $db->fetch_object($resql) ) {
@@ -261,11 +261,10 @@ if ($resql) {
$tmp = $obj->lettering_code;
if ($tmp != $obj->lettering_code || empty($obj->lettering_code))
- $var = ! $var;
$solde += ($obj->credit - $obj->debit);
- print "";
+ print ' ';
if (empty($obj->lettering_code)) {
print '';
@@ -293,14 +292,13 @@ if ($resql) {
}
print '';
-
print 'Mouvement totaux ' . "\n";
print '' . price($debit) . ' ';
print '' . price($credit) . ' ';
print ' ';
print " \n";
- print "";
+ print ' ';
print 'Solde Comptable ' . "\n";
print '' . price($credit - $debit) . ' ';
print ' ';
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
index cf278c26903..905361b4c8e 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville
* Copyright (C) 2005 Laurent Destailleur
* Copyright (C) 2013 Olivier Geffroy
- * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Florian Henry
* Copyright (C) 2013 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@
*/
/**
- * \file accounting/bookkeeping/thirdparty_lettrage.php
+ * \file accountancy/bookkeeping/thirdparty_lettrage_supplier.php
* \ingroup Advanced accountancy
* \brief Tab to setup lettering
*/
@@ -86,8 +86,9 @@ $socid = GETPOST("socid", 'int');
$object = new Societe($db);
$object->id = $socid;
$result = $object->fetch($socid);
-if ($result<0) {
- setEventMessage($object->error,'errors');
+if ($result<0)
+{
+ setEventMessages($object->error, $object->errors, 'errors');
}
$form = new Form($db);
@@ -133,7 +134,7 @@ if (!empty($search_doc_ref)) $param.='&search_doc_ref='.$search_doc_ref;
/*
- * Affichage onglets
+ * Display tabs
*/
$head = societe_prepare_head($object);
@@ -272,7 +273,6 @@ if ($resql) {
print '';
print ' ';
- $var = false;
$solde = 0;
$tmp = '';
while ($obj = $db->fetch_object($resql)) {
@@ -281,11 +281,10 @@ if ($resql) {
$tmp = $obj->lettering_code;
if ($tmp != $obj->lettering_code || empty($obj->lettering_code))
- $var = ! $var;
$solde += ($obj->credit - $obj->debit);
- print "";
+ print ' ';
if (empty($obj->lettering_code)) {
print '';
@@ -320,7 +319,7 @@ if ($resql) {
print ' ';
print " \n";
- print "";
+ print ' ';
print 'Solde Comptable ' . "\n";
print '' . price($credit - $debit) . ' ';
print ' ';
diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index 27254ef31d1..b0c3adb7edd 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -28,27 +28,97 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
/**
* Class to manage categories of an accounting account
*/
-class AccountancyCategory // extends CommonObject
+class AccountancyCategory // extends CommonObject
{
- public $db; //!< To store db handler
- public $error; //!< To return error code (or message)
- public $errors=array(); //!< To return several error codes (or messages)
- public $element='c_accounting_category'; //!< Id that identify managed objects
- public $table_element='c_accounting_category'; //!< Name of table without prefix where object is stored
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- public $id;
+ /**
+ * @var string Error string
+ * @see errors
+ */
+ public $error;
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='c_accounting_category';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='c_accounting_category';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $code;
- public $label;
+
+ /**
+ * @var string Accountancy Category label
+ */
+ public $label;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $range_account;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $sens;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $category_type;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $formula;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $position;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $fk_country;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $active;
+ /**
+ * @var mixed Sample property 1
+ */
public $lines_cptbk;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $lines_display;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $sdc;
@@ -125,18 +195,18 @@ class AccountancyCategory // extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_accounting_category");
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action call a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+ //if (! $notrigger)
+ //{
- //// Call triggers
- //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- //$interface=new Interfaces($this->db);
- //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
- //if ($result < 0) { $error++; $this->errors=$interface->errors; }
- //// End call triggers
- }
+ // // Call triggers
+ // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ // $interface=new Interfaces($this->db);
+ // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ // if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -264,18 +334,17 @@ class AccountancyCategory // extends CommonObject
if (! $error)
{
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action call a trigger.
-
- //// Call triggers
- //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- //$interface=new Interfaces($this->db);
- //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
- //if ($result < 0) { $error++; $this->errors=$interface->errors; }
- //// End call triggers
- }
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+ //if (! $notrigger)
+ //{
+ // // Call triggers
+ // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ // $interface=new Interfaces($this->db);
+ // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ // if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -320,18 +389,17 @@ class AccountancyCategory // extends CommonObject
if (! $error)
{
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action call a trigger.
-
- //// Call triggers
- //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- //$interface=new Interfaces($this->db);
- //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
- //if ($result < 0) { $error++; $this->errors=$interface->errors; }
- //// End call triggers
- }
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+ //if (! $notrigger)
+ //{
+ // // Call triggers
+ // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ // $interface=new Interfaces($this->db);
+ // $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ // if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -359,7 +427,8 @@ class AccountancyCategory // extends CommonObject
* @param int $id Id
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function display($id) {
+ public function display($id)
+ {
global $conf;
$sql = "SELECT t.rowid, t.account_number, t.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
@@ -394,7 +463,8 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function getCptBK($id) {
+ public function getCptBK($id)
+ {
global $conf;
$sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
@@ -442,8 +512,9 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function getAccountsWithNoCategory($id) {
- global $conf;
+ public function getAccountsWithNoCategory($id)
+ {
+ global $conf;
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
@@ -485,7 +556,8 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- public function updateAccAcc($id_cat, $cpts = array()) {
+ public function updateAccAcc($id_cat, $cpts = array())
+ {
global $conf;
$error = 0;
@@ -548,7 +620,8 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- public function deleteCptCat($cpt_id) {
+ public function deleteCptCat($cpt_id)
+ {
$error = 0;
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa";
@@ -799,5 +872,4 @@ class AccountancyCategory // extends CommonObject
return -1;
}
}
-
}
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 52b5f1c411f..40427d68034 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -55,11 +55,11 @@ class AccountancyExport
public static $EXPORT_TYPE_AGIRIS = 9;
public static $EXPORT_TYPE_CONFIGURABLE = 10;
+
/**
- *
* @var string[] Error codes (or messages)
*/
- public $errors = array ();
+ public $errors = array();
/**
*
@@ -78,7 +78,8 @@ class AccountancyExport
*
* @param DoliDb $db Database handler
*/
- public function __construct(DoliDB &$db) {
+ public function __construct(DoliDB &$db)
+ {
global $conf;
$this->db = &$db;
@@ -91,7 +92,8 @@ class AccountancyExport
*
* @return array of type
*/
- public static function getType() {
+ public static function getType()
+ {
global $langs;
return array (
@@ -113,7 +115,8 @@ class AccountancyExport
*
* @return array of type
*/
- public static function getTypeConfig() {
+ public static function getTypeConfig()
+ {
global $conf, $langs;
return array (
@@ -175,7 +178,8 @@ class AccountancyExport
*
* @return void
*/
- public static function downloadFile() {
+ public static function downloadFile()
+ {
global $conf;
$filename = 'general_ledger';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@@ -185,8 +189,10 @@ class AccountancyExport
* Function who chose which export to use with the default config
*
* @param unknown $TData data
+ * @return void
*/
- public function export(&$TData) {
+ public function export(&$TData)
+ {
global $conf, $langs;
self::downloadFile();
@@ -235,7 +241,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportNormal($objectLines) {
+ public function exportNormal($objectLines)
+ {
global $conf;
foreach ( $objectLines as $line ) {
@@ -259,7 +266,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCegid($objectLines) {
+ public function exportCegid($objectLines)
+ {
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
$separator = ";";
@@ -284,7 +292,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCogilog($objectLines) {
+ public function exportCogilog($objectLines)
+ {
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
$separator = ";";
@@ -317,7 +326,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCoala($objectLines) {
+ public function exportCoala($objectLines)
+ {
// Coala export
$separator = ";";
$end_line = "\n";
@@ -344,7 +354,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportBob50($objectLines) {
+ public function exportBob50($objectLines)
+ {
// Bob50
$separator = ";";
@@ -382,7 +393,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCiel(&$TData) {
+ public function exportCiel(&$TData)
+ {
global $conf;
$end_line ="\r\n";
@@ -422,7 +434,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportQuadratus(&$TData) {
+ public function exportQuadratus(&$TData)
+ {
global $conf;
$end_line ="\r\n";
@@ -505,7 +518,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportEbp($objectLines) {
+ public function exportEbp($objectLines)
+ {
$separator = ',';
$end_line = "\n";
@@ -537,7 +551,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportAgiris($objectLines) {
+ public function exportAgiris($objectLines)
+ {
$separator = ';';
$end_line = "\n";
@@ -574,7 +589,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportConfigurable($objectLines) {
+ public function exportConfigurable($objectLines)
+ {
global $conf;
foreach ($objectLines as $line) {
@@ -602,8 +618,10 @@ class AccountancyExport
*
* @param unknown $str data
* @param integer $size data
+ * @return string
*/
- public static function trunc($str, $size) {
+ public static function trunc($str, $size)
+ {
return dol_trunc($str, $size, 'right', 'UTF-8', 1);
}
}
diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php
index f14a3e7f761..d126bd84acc 100644
--- a/htdocs/accountancy/class/accountancysystem.class.php
+++ b/htdocs/accountancy/class/accountancysystem.class.php
@@ -28,13 +28,26 @@
*/
class AccountancySystem
{
- var $db;
- var $error;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
var $rowid;
var $fk_pcg_version;
var $pcg_type;
var $pcg_subtype;
- var $label;
+
+ /**
+ * @var string Accountancy System label
+ */
+ public $label;
+
var $account_number;
var $account_parent;
@@ -43,7 +56,8 @@ class AccountancySystem
*
* @param DoliDB $db handler
*/
- function __construct($db) {
+ function __construct($db)
+ {
$this->db = $db;
}
@@ -102,7 +116,8 @@ class AccountancySystem
* @param User $user making insert
* @return int if KO, Id of line if OK
*/
- function create($user) {
+ function create($user)
+ {
$now = dol_now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
@@ -130,4 +145,4 @@ class AccountancySystem
return $result;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 257c2af0111..4929e118a3b 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -31,7 +31,15 @@
class AccountingAccount extends CommonObject
{
public $element='accounting_account';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='accounting_account';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'billr';
/**
@@ -39,29 +47,63 @@ class AccountingAccount extends CommonObject
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
*/
public $restrictiononfksoc = 1;
- var $db;
- var $error;
- var $errors;
- var $id;
- var $rowid;
- var $datec; // Creation date
- var $fk_pcg_version;
- var $pcg_type;
- var $pcg_subtype;
- var $account_number;
- var $account_parent;
- var $account_category;
- var $label;
- var $fk_user_author;
- var $fk_user_modif;
- var $active; // duplicate with status
- var $status;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var int ID
+ */
+ public $rowid;
+
+ public $datec; // Creation date
+ public $fk_pcg_version;
+ public $pcg_type;
+ public $pcg_subtype;
+ public $account_number;
+ public $account_parent;
+ public $account_category;
+ public $status;
+
+ /**
+ * @var string Label of account
+ */
+ public $label;
+
+ /**
+ * @var int ID
+ */
+ public $fk_user_author;
+
+ /**
+ * @var int ID
+ */
+ public $fk_user_modif;
+
+ public $active; // duplicate with status
/**
@@ -69,7 +111,8 @@ class AccountingAccount extends CommonObject
*
* @param DoliDB $db Database handle
*/
- function __construct($db) {
+ function __construct($db)
+ {
global $conf;
$this->db = $db;
@@ -146,7 +189,8 @@ class AccountingAccount extends CommonObject
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/
- function create($user, $notrigger = 0) {
+ function create($user, $notrigger = 0)
+ {
global $conf;
$error = 0;
$now = dol_now();
@@ -297,7 +341,8 @@ class AccountingAccount extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- function checkUsage() {
+ function checkUsage()
+ {
global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
@@ -330,7 +375,8 @@ class AccountingAccount extends CommonObject
* @param int $notrigger 0=triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
- function delete($user, $notrigger = 0) {
+ function delete($user, $notrigger = 0)
+ {
$error = 0;
$result = $this->checkUsage();
@@ -391,7 +437,7 @@ class AccountingAccount extends CommonObject
* @param string $moretitle Add more text to title tooltip
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
+ * @return string String with URL
*/
function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0, $save_lastsearch_value=-1)
{
@@ -457,7 +503,8 @@ class AccountingAccount extends CommonObject
* @param int $id of record
* @return void
*/
- function info($id) {
+ function info($id)
+ {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a';
$sql .= ' WHERE a.rowid = ' . $id;
@@ -488,13 +535,16 @@ class AccountingAccount extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Account deactivated
*
* @param int $id Id
* @return int <0 if KO, >0 if OK
*/
- function account_desactivate($id) {
+ function account_desactivate($id)
+ {
+ // phpcs:enable
$result = $this->checkUsage();
if ($result > 0) {
@@ -520,13 +570,16 @@ class AccountingAccount extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Account activated
*
* @param int $id Id
* @return int <0 if KO, >0 if OK
*/
- function account_activate($id) {
+ function account_activate($id)
+ {
+ // phpcs:enable
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
@@ -557,6 +610,7 @@ class AccountingAccount extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -566,6 +620,7 @@ class AccountingAccount extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
$langs->loadLangs(array("users"));
@@ -575,27 +630,27 @@ class AccountingAccount extends CommonObject
if ($statut == 1) return $langs->trans('Enabled');
if ($statut == 0) return $langs->trans('Disabled');
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
if ($statut == 1) return $langs->trans('Enabled');
if ($statut == 0) return $langs->trans('Disabled');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php
index 454de6d7b84..058bdb3dddb 100644
--- a/htdocs/accountancy/class/accountingjournal.class.php
+++ b/htdocs/accountancy/class/accountingjournal.class.php
@@ -26,16 +26,40 @@
*/
class AccountingJournal extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='accounting_journal';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='accounting_journal';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element = '';
+
public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'generic';
- var $rowid;
+ /**
+ * @var int ID
+ */
+ public $rowid;
public $code;
- public $label;
+
+ /**
+ * @var string Accounting Journal label
+ */
+ public $label;
+
public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
public $active;
@@ -46,7 +70,8 @@ class AccountingJournal extends CommonObject
*
* @param DoliDB $db Database handle
*/
- function __construct($db) {
+ function __construct($db)
+ {
$this->db = $db;
}
@@ -117,7 +142,8 @@ class AccountingJournal extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
+ function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
$sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
@@ -245,6 +271,7 @@ class AccountingJournal extends CommonObject
return $this->LibType($this->nature,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return type of an accounting journal
*
@@ -254,6 +281,7 @@ class AccountingJournal extends CommonObject
*/
function LibType($nature,$mode=0)
{
+ // phpcs:enable
global $langs;
$langs->loadLangs(array("accountancy"));
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index f7fed2e2b5b..5d9572da684 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -35,19 +35,25 @@ class BookKeeping extends CommonObject
* @var string Error code (or message)
*/
public $error;
+
/**
* @var string[] Error codes (or messages)
*/
- public $errors = array ();
+ public $errors = array();
+
/**
* @var string Id to identify managed objects
*/
public $element = 'accountingbookkeeping';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'accounting_bookkeeping';
+ /**
+ * @var int Entity
+ */
public $entity;
/**
@@ -59,8 +65,7 @@ class BookKeeping extends CommonObject
* @var int ID
*/
public $id;
- /**
- */
+
public $doc_date;
public $date_lim_reglement;
public $doc_type;
@@ -88,7 +93,8 @@ class BookKeeping extends CommonObject
*
* @param DoliDb $db Database handler
*/
- public function __construct(DoliDB $db) {
+ public function __construct(DoliDB $db)
+ {
$this->db = $db;
}
@@ -99,7 +105,8 @@ class BookKeeping extends CommonObject
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
- public function create(User $user, $notrigger = false) {
+ public function create(User $user, $notrigger = false)
+ {
global $conf, $langs;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -328,18 +335,15 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
- if (! $error) {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action to call a trigger.
+ //if (! $error && ! $notrigger) {
- if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action to call a trigger.
-
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
- // if ($result < 0) $error++;
- // // End call triggers
- }
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
+ // if ($result < 0) $error++;
+ // // End call triggers
+ //}
// Commit or rollback
if ($error) {
@@ -420,7 +424,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, Id of created object if OK
*/
- public function createStd(User $user, $notrigger = false, $mode='') {
+ public function createStd(User $user, $notrigger = false, $mode='')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -558,15 +563,15 @@ class BookKeeping extends CommonObject
if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element . $mode);
- if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action to call a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action to call a trigger.
+ //if (! $notrigger) {
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
- // if ($result < 0) $error++;
- // // End call triggers
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
+ // if ($result < 0) $error++;
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -590,7 +595,8 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function fetch($id, $ref = null, $mode='') {
+ public function fetch($id, $ref = null, $mode='')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -687,7 +693,8 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, >=0 if OK
*/
- public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
+ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -811,7 +818,8 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -1016,7 +1024,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- public function update(User $user, $notrigger = false, $mode='') {
+ public function update(User $user, $notrigger = false, $mode='')
+ {
$error = 0;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -1119,15 +1128,15 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
- if (! $error && ! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+ //if (! $error && ! $notrigger) {
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_MODIFY',$user);
- // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- // // End call triggers
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+ // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ // // End call triggers
+ //}
// Commit or rollback
if ($error) {
@@ -1185,24 +1194,23 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- public function delete(User $user, $notrigger = false, $mode='') {
+ public function delete(User $user, $notrigger = false, $mode='')
+ {
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
$this->db->begin();
- if (! $error) {
- if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+ //if (! $error && ! $notrigger) {
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_DELETE',$user);
- // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- // // End call triggers
- }
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_DELETE',$user);
+ // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ // // End call triggers
+ //}
if (! $error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode;
@@ -1234,7 +1242,8 @@ class BookKeeping extends CommonObject
* @param string $importkey Import key
* @return int Result
*/
- function deleteByImportkey($importkey) {
+ function deleteByImportkey($importkey)
+ {
$this->db->begin();
// first check if line not yet in bookkeeping
@@ -1263,7 +1272,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- function deleteByYearAndJournal($delyear='', $journal='', $mode='') {
+ function deleteByYearAndJournal($delyear='', $journal='', $mode='')
+ {
global $conf;
if (empty($delyear) && empty($journal))
@@ -1302,7 +1312,8 @@ class BookKeeping extends CommonObject
* @param int $piecenum Piecenum to delete
* @return int Result
*/
- function deleteMvtNum($piecenum) {
+ function deleteMvtNum($piecenum)
+ {
global $conf;
$this->db->begin();
@@ -1336,7 +1347,8 @@ class BookKeeping extends CommonObject
*
* @return int New id of clone
*/
- public function createFromClone($fromid) {
+ public function createFromClone($fromid)
+ {
dol_syslog(__METHOD__, LOG_DEBUG);
global $user;
@@ -1381,7 +1393,8 @@ class BookKeeping extends CommonObject
*
* @return void
*/
- public function initAsSpecimen() {
+ public function initAsSpecimen()
+ {
global $user;
$now=dol_now();
@@ -1417,7 +1430,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- public function fetchPerMvt($piecenum, $mode='') {
+ public function fetchPerMvt($piecenum, $mode='')
+ {
global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation";
@@ -1481,7 +1495,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- function fetchAllPerMvt($piecenum, $mode='') {
+ function fetchAllPerMvt($piecenum, $mode='')
+ {
global $conf;
$sql = "SELECT rowid, doc_date, doc_type,";
@@ -1533,13 +1548,16 @@ class BookKeeping extends CommonObject
return 1;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Export bookkeping
*
* @param string $model Model
* @return int Result
*/
- function export_bookkeping($model = 'ebp') {
+ function export_bookkeping($model = 'ebp')
+ {
+ // phpcs:enable
global $conf;
$sql = "SELECT rowid, doc_date, doc_type,";
@@ -1684,19 +1702,22 @@ class BookKeeping extends CommonObject
*/
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of accounts with label by chart of accounts
*
- * @param string $selectid Preselected chart of accounts
- * @param string $htmlname Name of field in html form
+ * @param string $selectid Preselected chart of accounts
+ * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @return string String with HTML select
- */
- function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
+ */
+ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
+ {
+ // phpcs:enable
global $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@@ -1753,6 +1774,7 @@ class BookKeeping extends CommonObject
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Description of a root accounting account
*
@@ -1761,6 +1783,7 @@ class BookKeeping extends CommonObject
*/
function get_compte_racine($account = null)
{
+ // phpcs:enable
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
@@ -1793,6 +1816,7 @@ class BookKeeping extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Description of accounting account
*
@@ -1801,6 +1825,7 @@ class BookKeeping extends CommonObject
*/
function get_compte_desc($account = null)
{
+ // phpcs:enable
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
@@ -1838,7 +1863,11 @@ class BookKeeping extends CommonObject
*/
class BookKeepingLine
{
+ /**
+ * @var int ID
+ */
public $id;
+
public $doc_date = '';
public $doc_type;
public $doc_ref;
diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php
index 7e1387db951..677bc627c80 100644
--- a/htdocs/accountancy/customer/card.php
+++ b/htdocs/accountancy/customer/card.php
@@ -159,5 +159,6 @@ if (! empty($id)) {
print "Error ID incorrect";
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 18e23826314..4f4932fe08f 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -89,7 +89,7 @@ if ($action == 'clean' || $action == 'validatehistory')
if (! $resql1) {
$error ++;
$db->rollback();
- setEventMessage($db->lasterror(), 'errors');
+ setEventMessages($db->lasterror(), null, 'errors');
} else {
$db->commit();
}
@@ -153,7 +153,7 @@ $y = $year_current;
$buttonbind = '' . $langs->trans("ValidateHistory") . ' ';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
-//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
+//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php
index afb2d31efce..be5f785f9e4 100644
--- a/htdocs/admin/const.php
+++ b/htdocs/admin/const.php
@@ -37,11 +37,11 @@ $rowid=GETPOST('rowid','int');
$entity=GETPOST('entity','int');
$action=GETPOST('action','alpha');
$update=GETPOST('update','alpha');
-$delete=GETPOST('delete'); // Do not use alpha here
+$delete=GETPOST('delete','none'); // Do not use alpha here
$debug=GETPOST('debug','int');
$consts=GETPOST('const','array');
$constname=GETPOST('constname','alpha');
-$constvalue=GETPOST('constvalue');
+$constvalue=GETPOST('constvalue','none'); // We shoul dbe able to send everything here
$constnote=GETPOST('constnote','alpha');
@@ -248,7 +248,7 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
-
+
print "\n";
@@ -314,7 +314,6 @@ if ($conf->use_javascript_ajax)
print "\n";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index 74f7acb04f3..60be9e062ba 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -509,7 +509,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php
index 4f3d45294a9..e882a56e2b8 100644
--- a/htdocs/admin/dav.php
+++ b/htdocs/admin/dav.php
@@ -35,7 +35,10 @@ if (!$user->admin)
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
-$arrayofparameters=array('DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200'));
+$arrayofparameters=array(
+ 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
+ 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
+);
/*
@@ -76,6 +79,8 @@ if ($action == 'edit')
foreach($arrayofparameters as $key => $val)
{
+ if (isset($val['enabled']) && empty($val['enabled'])) continue;
+
print ' ';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
print ' ';
@@ -138,6 +143,6 @@ $message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'Web
$message.=' ';
print $message;
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index 0633ee90965..984ddfbefd7 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -34,7 +34,7 @@ if (!$user->admin) accessforbidden();
$id=GETPOST('rowid','int');
$action=GETPOST('action','alpha');
-$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
+$mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
@@ -412,7 +412,6 @@ dol_fiche_end();
print "\n";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php
index ae3c43c5b24..19fa67abcff 100644
--- a/htdocs/admin/delais.php
+++ b/htdocs/admin/delais.php
@@ -122,6 +122,13 @@ $modules=array(
),
);
+$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
+
+
+/*
+ * Actions
+ */
+
if ($action == 'update')
{
foreach($modules as $module => $delays)
@@ -201,9 +208,10 @@ if ($action == 'edit')
print ' ';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- $var=false;
print '';
- print ''.$langs->trans("MAIN_DISABLE_METEO").' ' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . ' ';
+ print ''.$langs->trans("MAIN_DISABLE_METEO").' ';
+ print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO));
+ print ' ';
print '
';
}
@@ -241,7 +249,9 @@ else
print ' '.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
print '';
- print ''.$langs->trans("MAIN_DISABLE_METEO").' ' . yn($conf->global->MAIN_DISABLE_METEO) . ' ';
+ print ''.$langs->trans("MAIN_DISABLE_METEO").' ';
+ print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
+ print ' ';
print '';
@@ -415,5 +425,6 @@ if($action == 'edit') {
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index c50985be5fc..0c25f3a5bd8 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -261,7 +261,7 @@ $tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_
$tabfield[11]= "element,source,code,libelle,position";
$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
$tabfield[13]= "code,libelle,type,entity";
-$tabfield[14]= "code,label,price,organization,country_id,country";
+$tabfield[14]= "code,label,price,organization,country";
$tabfield[15]= "code,libelle,width,height,unit";
$tabfield[16]= "code,libelle,sortorder";
$tabfield[17]= "code,label,accountancy_code";
@@ -379,7 +379,7 @@ $tabrowid[9] = "code_iso";
$tabrowid[10]= "";
$tabrowid[11]= "rowid";
$tabrowid[12]= "";
-$tabrowid[13]= "";
+$tabrowid[13]= "id";
$tabrowid[14]= "";
$tabrowid[15]= "";
$tabrowid[16]= "code";
@@ -1735,7 +1735,7 @@ else
print ' ';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php
index 14d05a036e8..c1bb4e997dc 100644
--- a/htdocs/admin/dolistore/ajax/image.php
+++ b/htdocs/admin/dolistore/ajax/image.php
@@ -20,22 +20,11 @@ if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
/**
- * \file htdocs/commande/info.php
- * \ingroup commande
- * \brief Page des informations d'une commande
+ * \file htdocs/admin/dolistore/ajax/image.php
+ * \ingroup admin
+ * \brief Page des informations dolistore
*/
-$res = 0;
-if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php");
-if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php");
-if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php");
-if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php");
-if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php"))
- $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
-if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php"))
- $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
-if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php"))
- $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
-if (!$res) die("Include of main fails");
+require "../../../main.inc.php";
// CORE
@@ -52,8 +41,10 @@ $quality = GETPOST('quality', 'alpha');
try {
$url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
- $api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
- $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api);
+ $api = new PrestaShopWebservice(
+ $conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
+ $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api
+ );
//echo $url;
$request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
header('Content-type:image');
@@ -65,4 +56,3 @@ try {
else if ($trace[0]['args'][0] == 401) die('Bad auth key');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
}
-
diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
index de3ca683519..4617481d04d 100644
--- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
+++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
@@ -53,7 +53,7 @@ class PrestaShopWebservice
* PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated
*
* url = $url;
@@ -82,6 +83,7 @@ class PrestaShopWebservice
* Take the status code and throw an exception if the server didn't return 200 or 201 code
*
* @param int $status_code Status code of an HTTP return
+ * @return void
*/
protected function checkStatusCode($status_code)
{
@@ -279,7 +281,7 @@ class PrestaShopWebservice
*
*
* 'PUT', CURLOPT_POSTFIELDS => $xml));
+ $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml));
self::checkStatusCode($request['status_code']);// check the response validity
return self::parseXML($request['response']);
}
diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php
index 07dbec4b902..859b9140f86 100644
--- a/htdocs/admin/dolistore/class/dolistore.class.php
+++ b/htdocs/admin/dolistore/class/dolistore.class.php
@@ -25,9 +25,18 @@ include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class
*/
class Dolistore
{
- // params
- public $start; // beginning of pagination
- public $end; // end of pagination
+ /**
+ * beginning of pagination
+ * @var int
+ */
+
+ public $start;
+ /**
+ * end of pagination
+ * @var int
+ */
+ public $end;
+
public $per_page; // pagination: display per page
public $categorie; // the current categorie
public $search; // the search keywords
@@ -42,19 +51,21 @@ class Dolistore
/**
* Constructor
+ *
+ * @param boolean $debug Enable debug of request on screen
*/
- function __construct()
+ function __construct($debug=false)
{
global $conf, $langs;
$this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
$this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product=';
$this->vat_rate = 1.2; // 20% de TVA
- $this->debug_api = false;
+ $this->debug_api = $debug;
$langtmp = explode('_', $langs->defaultlang);
$lang = $langtmp[0];
- $lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1
+ $lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
if (! in_array($lang, array_keys($lang_array))) $lang = 'en';
$this->lang = $lang_array[$lang];
}
@@ -81,18 +92,25 @@ class Dolistore
}
try {
- $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
- $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
+ $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
+ dol_syslog("Call API with MAIN_MODULE_DOLISTORE_API_SRV = ".$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
+ // $conf->global->MAIN_MODULE_DOLISTORE_API_KEY is for the login of basic auth. There is no password as it is public data.
// Here we set the option array for the Webservice : we want products resources
$opt = array();
$opt['resource'] = 'products';
+ $opt2 = array();
// make a search to limit the id returned.
if ($this->search != '') {
- $opt2 = array();
$opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang;
+
// Call
+ //var_dump($this->api);
+
+ dol_syslog("Call API with opt = ".var_export($opt, true));
+ dol_syslog("Call API with opt2 = ".var_export($opt2, true));
+
$xml = $this->api->get($opt2);
$products = array();
foreach ($xml->products->children() as $product) {
@@ -100,7 +118,6 @@ class Dolistore
}
$opt['filter[id]'] = '['.implode('|', $products).']';
} elseif ($this->categorie != 0) {
- $opt2 = array();
$opt2['resource'] = 'categories';
$opt2['id'] = $this->categorie;
// Call
@@ -117,7 +134,10 @@ class Dolistore
$opt['limit'] = "$this->start,$this->end";
// $opt['filter[id]'] contais list of product id that are result of search
+
// Call API to get the detail
+ dol_syslog("Call API with opt = ".var_export($opt, true));
+ dol_syslog("Call API with opt2 = ".var_export($opt2, true));
$xml = $this->api->get($opt);
$this->products = $xml->products->children();
@@ -135,10 +155,15 @@ class Dolistore
$trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID');
else if ($trace[0]['args'][0] == 401) die('Bad auth key');
- else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
+ else
+ {
+ print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.' ';
+ print $e->getMessage();
+ }
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return tree of Dolistore categories. $this->categories must have been loaded before.
*
@@ -147,6 +172,7 @@ class Dolistore
*/
function get_categories($parent = 0)
{
+ // phpcs:enable
if (!isset($this->categories)) die('not possible');
if ($parent != 0) {
$html = '';
@@ -186,6 +212,7 @@ class Dolistore
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of product formated for output
*
@@ -193,6 +220,7 @@ class Dolistore
*/
function get_products()
{
+ // phpcs:enable
global $langs, $conf;
$html = "";
$parity = "pair";
@@ -267,18 +295,41 @@ class Dolistore
return $html;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get previous link
+ *
+ * @param string $text symbol previous
+ * @return string html previous link
+ */
function get_previous_link($text = '<<')
{
+ // phpcs:enable
return ''.$text.' ';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get next link
+ *
+ * @param string $text symbol next
+ * @return string html next link
+ */
function get_next_link($text = '>>')
{
+ // phpcs:enable
return ''.$text.' ';
}
- function get_previous_url()
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get previous url
+ *
+ * @return string previous url
+ */
+ function get_previous_url()
{
+ // phpcs:enable
$param_array = array();
if ($this->start < $this->per_page) {
$sub = 0;
@@ -294,8 +345,15 @@ class Dolistore
return $this->url."&".$param;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get next url
+ *
+ * @return string next url
+ */
function get_next_url()
{
+ // phpcs:enable
$param_array = array();
if (count($this->products) < $this->per_page) {
$add = 0;
@@ -311,8 +369,17 @@ class Dolistore
return $this->url."&".$param;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * version compare
+ *
+ * @param string $v1 version 1
+ * @param string $v2 version 2
+ * @return int result of compare
+ */
function version_compare($v1, $v2)
{
+ // phpcs:enable
$v1 = explode('.', $v1);
$v2 = explode('.', $v2);
$ret = 0;
@@ -340,4 +407,3 @@ class Dolistore
return $ret;
}
}
-
diff --git a/htdocs/admin/dolistore/css/dolistore.css b/htdocs/admin/dolistore/css/dolistore.css
index bba808a21a0..fb4dc2d5bb1 100644
--- a/htdocs/admin/dolistore/css/dolistore.css
+++ b/htdocs/admin/dolistore/css/dolistore.css
@@ -6,10 +6,10 @@ div.divsearchfield {
}
.margeCoteGauche,.margeCote{
- padding-right: 20px!important;
+ padding-right: 20px!important;
}
.margeCote,.margeCoteDroite{
- padding-left: 20px!important;
+ padding-left: 20px!important;
}
.nomargesupinf{
margin-top: 0;
@@ -26,13 +26,13 @@ div.divsearchfield {
width: 100%;
}
.tree{
- margin: 0px 0px 0px 0px;
+ margin: 0px 0px 0px 0px;
padding:0px;
list-style: none; line-height: 2em; font-family: Arial;
}
.tree li{
font-size: 16px;
- position: relative;list-style: none;
+ position: relative;list-style: none;
}
.tree li:before{
position: absolute;
@@ -65,7 +65,7 @@ div.divsearchfield {
.tree li.root:after{
display: none;
}
-.tree li:last-child:after{
+.tree li:last-child:after{
display: none
}
.blockUI {
@@ -159,7 +159,7 @@ textarea.row4{
.reviewList {
max-height: 150px;
- overflow-y: scroll;
+ overflow-y: scroll;
}
.reviewRow{
diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php
index dc2f3e489f7..3126f432938 100644
--- a/htdocs/admin/ecm.php
+++ b/htdocs/admin/ecm.php
@@ -109,5 +109,6 @@ print '';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php
index 1d1ec548853..dd3b1c5bff7 100644
--- a/htdocs/admin/events.php
+++ b/htdocs/admin/events.php
@@ -94,7 +94,7 @@ print "\n";
foreach ($eventstolog as $key => $arr)
{
if ($arr['id'])
- {
+ {
print '';
print ''.$arr['id'].' ';
print '';
@@ -114,6 +114,6 @@ print "";
print "\n";
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index eb18f904229..c851010635e 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -507,5 +507,6 @@ print '";
}
@@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php
index 5567e9480e8..cc5a9bddfa5 100644
--- a/htdocs/admin/expeditiondet_extrafields.php
+++ b/htdocs/admin/expeditiondet_extrafields.php
@@ -88,7 +88,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -101,7 +101,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -120,6 +120,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php
index 1002b146113..78287f71eab 100644
--- a/htdocs/admin/expensereport.php
+++ b/htdocs/admin/expensereport.php
@@ -513,7 +513,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php
index 8db81edb869..3fedf935405 100644
--- a/htdocs/admin/expensereport_extrafields.php
+++ b/htdocs/admin/expensereport_extrafields.php
@@ -83,7 +83,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -96,7 +96,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -115,6 +115,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php
index db7100d5928..d3937a98ba7 100644
--- a/htdocs/admin/expensereport_ik.php
+++ b/htdocs/admin/expensereport_ik.php
@@ -179,6 +179,7 @@ echo '';
echo '';
dol_fiche_end();
-llxFooter();
+// End of page
+llxFooter();
$db->close();
diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php
index b1d65b8635b..7b2baf0ed94 100644
--- a/htdocs/admin/expensereport_rules.php
+++ b/htdocs/admin/expensereport_rules.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2017 ATM Consulting
- * Copyright (C) 2017 Pierre-Henry Favre
+/* Copyright (C) 2012 Mikael Carlavan
+ * Copyright (C) 2017 ATM Consulting
+ * Copyright (C) 2017 Pierre-Henry Favre
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -182,8 +183,8 @@ if ($action != 'edit')
echo ''.$form->selectExpense('', 'fk_c_type_fees', 0, 1, 1).' ';
echo ''.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).' ';
- echo ''.$form->select_date(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0, 1).' ';
- echo ''.$form->select_date(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0, 1).' ';
+ echo ''.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).' ';
+ echo ''.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).' ';
echo ' '.$conf->currency.' ';
echo ''.$form->selectyesno('restrictive', 0, 1).' ';
echo ' ';
@@ -270,7 +271,7 @@ foreach ($rules as $rule)
echo '';
if ($action == 'edit' && $object->id == $rule->id)
{
- echo $form->select_date(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0, 1);
+ print $form->selectDate(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0);
}
else
{
@@ -282,7 +283,7 @@ foreach ($rules as $rule)
echo ' ';
if ($action == 'edit' && $object->id == $rule->id)
{
- echo $form->select_date(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0, 1);
+ print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0);
}
else
{
@@ -354,6 +355,7 @@ echo '';
dol_fiche_end();
-llxFooter();
+// End of page
+llxFooter();
$db->close();
diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php
index b6f12a723ff..292c3604799 100644
--- a/htdocs/admin/export.php
+++ b/htdocs/admin/export.php
@@ -6,7 +6,7 @@
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011-2012 Juanjo Menent
- * Copyright (C) 2011-2015 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,9 +32,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
-$langs->loadLangs(array('admin', 'exports'));
-
-$langs->load('other');
+$langs->loadLangs(array('admin', 'exports', 'other'));
if (! $user->admin)
accessforbidden();
@@ -73,7 +71,7 @@ dol_fiche_head(
// Setup page goes here
$form=new Form($db);
-$var=false;
+
print '';
print '';
print ''.$langs->trans("ExportModel").' '."\n";
@@ -82,8 +80,7 @@ print ' '."\n";
// Example with a yes / no select
-$var=!$var;
-print ' ';
+print ' ';
print ''.$langs->trans("set_EXPORTS_SHARE_MODELS").' ';
print ' ';
print '';
@@ -94,9 +91,8 @@ echo ajax_constantonoff('EXPORTS_SHARE_MODELS');
print '';
print ' ';
-
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php
index e8683dfc4ee..e0f3f72f927 100644
--- a/htdocs/admin/external_rss.php
+++ b/htdocs/admin/external_rss.php
@@ -325,6 +325,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index f00d125a4d5..6c28081e6fc 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -782,7 +782,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php
index 19d4a4cc772..bed1d4d9bcb 100644
--- a/htdocs/admin/fckeditor.php
+++ b/htdocs/admin/fckeditor.php
@@ -234,6 +234,6 @@ else
*/
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index a216f2d4ab7..c714c0c6c1b 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -6,7 +6,7 @@
* Copyright (C) 2005-2014 Regis Houssin
* Copyright (C) 2008 Raphael Bertrand (Resultic)
* Copyright (C) 2011-2013 Juanjo Menent
- * Copyright (C) 2011-2017 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
*
* 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
@@ -560,7 +560,6 @@ print " \n";
print '';
//Use draft Watermark
-
print " ';
-
-
-
print '';
print ' ';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php
index 9c944324527..9f154591f0f 100644
--- a/htdocs/admin/geoipmaxmind.php
+++ b/htdocs/admin/geoipmaxmind.php
@@ -153,6 +153,6 @@ if ($geoip)
$geoip->close();
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
new file mode 100644
index 00000000000..f6306f787c3
--- /dev/null
+++ b/htdocs/admin/holiday.php
@@ -0,0 +1,516 @@
+
+ * Copyright (C) 2011-2018 Philippe Grand
+ * Copyright (C) 2018 Charlene Benke
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/admin/contract.php
+ * \ingroup contract
+ * \brief Setup page of module Contracts
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("admin", "errors", "holiday"));
+
+if (!$user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+$label = GETPOST('label','alpha');
+$scandir = GETPOST('scan_dir','alpha');
+$type='contract';
+
+if (empty($conf->global->HOLIDAY_ADDON))
+{
+ $conf->global->HOLIDAY_ADDON='mod_holiday_madona';
+}
+
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+
+if ($action == 'updateMask')
+{
+ $maskconst = GETPOST('maskconstholidaty','alpha');
+ $maskvalue = GETPOST('maskholiday','alpha');
+ if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+}
+
+else if ($action == 'specimen') // For contract
+{
+ $modele= GETPOST('module','alpha');
+
+ $contract = new Contrat($db);
+ $contract->initAsSpecimen();
+
+ // Search template files
+ $file=''; $classname=''; $filefound=0;
+ $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+ foreach($dirmodels as $reldir)
+ {
+ $file=dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php",0);
+ if (file_exists($file))
+ {
+ $filefound=1;
+ $classname = "pdf_".$modele;
+ break;
+ }
+ }
+
+ if ($filefound)
+ {
+ require_once $file;
+
+ $module = new $classname($db);
+
+ if ($module->write_file($contract,$langs) > 0)
+ {
+ header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf");
+ return;
+ }
+ else
+ {
+ setEventMessages($obj->error, $obj->errors, 'errors');
+ dol_syslog($obj->error, LOG_ERR);
+ }
+ }
+ else
+ {
+ setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+ dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+ }
+}
+
+// Activate a model
+else if ($action == 'set')
+{
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+}
+
+else if ($action == 'del')
+{
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0)
+ {
+ if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF',$conf->entity);
+ }
+}
+
+// Set default model
+else if ($action == 'setdoc')
+{
+ if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+ {
+ // La constante qui a ete lue en avant du nouveau set
+ // on passe donc par une variable pour avoir un affichage coherent
+ $conf->global->HOLIDAY_ADDON_PDF = $value;
+ }
+
+ // On active le modele
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0)
+ {
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+ }
+}
+
+else if ($action == 'setmod')
+{
+ // TODO Verifier si module numerotation choisi peut etre active
+ // par appel methode canBeActivated
+
+ dolibarr_set_const($db, "HOLIDAY_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+else if ($action == 'set_other')
+{
+ $freetext= GETPOST('HOLIDAY_FREE_TEXT','none'); // No alpha here, we want exact string
+ $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
+
+ $draft= GETPOST('HOLIDAY_DRAFT_WATERMARK','alpha');
+ $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+
+ if (! $res1 > 0 || ! $res2 > 0) $error++;
+
+ if (! $error)
+ {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+}
+
+
+/*
+ * View
+ */
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+llxHeader();
+
+$form=new Form($db);
+
+$linkback=''.$langs->trans("BackToModuleList").' ';
+print load_fiche_titre($langs->trans("HolidaySetup"),$linkback,'title_setup');
+
+$head=holiday_admin_prepare_head();
+
+dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday');
+
+/*
+ * Holiday Numbering model
+ */
+
+print load_fiche_titre($langs->trans("HolidaysNumberingModules"),'','');
+
+print '';
+print '';
+print ''.$langs->trans("Name").' ';
+print ''.$langs->trans("Description").' ';
+print ''.$langs->trans("Example").' ';
+print ''.$langs->trans("Status").' ';
+print ''.$langs->trans("ShortInfo").' ';
+print " \n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+ $dir = dol_buildpath($reldir."core/modules/holiday/");
+
+ if (is_dir($dir))
+ {
+ $handle = opendir($dir);
+ if (is_resource($handle))
+ {
+ $var=true;
+
+ while (($file = readdir($handle))!==false)
+ {
+ if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+ {
+ $file = substr($file, 0, dol_strlen($file)-4);
+
+ require_once $dir.$file.'.php';
+
+ $module = new $file($db);
+
+ // Show modules according to features level
+ if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+ if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
+ if ($module->isEnabled())
+ {
+
+ print ''.$module->nom." \n";
+ print $module->info();
+ print ' ';
+
+ // Show example of numbering model
+ print '';
+ $tmp=$module->getExample();
+ if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print ''.$langs->trans($tmp).'
'; }
+ elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+ else print $tmp;
+ print ' '."\n";
+
+ print '';
+ if ($conf->global->HOLIDAY_ADDON == "$file")
+ {
+ print img_picto($langs->trans("Activated"),'switch_on');
+ }
+ else
+ {
+ print '';
+ print img_picto($langs->trans("Disabled"),'switch_off');
+ print ' ';
+ }
+ print ' ';
+
+ $holiday=new Holiday($db);
+ $holiday->initAsSpecimen();
+
+ // Info
+ $htmltooltip='';
+ $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().' ';
+ $nextval=$module->getNextValue($mysoc,$contract);
+ if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
+ $htmltooltip.=''.$langs->trans("NextValue").': ';
+ if ($nextval) {
+ if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
+ $nextval = $langs->trans($nextval);
+ $htmltooltip.=$nextval.' ';
+ } else {
+ $htmltooltip.=$langs->trans($module->error).' ';
+ }
+ }
+
+ print '';
+ print $form->textwithpicto('',$htmltooltip,1,0);
+ print ' ';
+
+ print ' ';
+ }
+ }
+ }
+ closedir($handle);
+ }
+ }
+}
+
+print '
';
+
+/*
+ * Documents models for Contracts
+ */
+
+print load_fiche_titre($langs->trans("TemplatePDFHolidays"),'','');
+
+// Defini tableau def des modeles
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$sql.= " AND entity = ".$conf->entity;
+$resql=$db->query($sql);
+if ($resql)
+{
+ $i = 0;
+ $num_rows=$db->num_rows($resql);
+ while ($i < $num_rows)
+ {
+ $array = $db->fetch_array($resql);
+ array_push($def, $array[0]);
+ $i++;
+ }
+}
+else
+{
+ dol_print_error($db);
+}
+
+
+print '';
+print '';
+print ''.$langs->trans("Name").' ';
+print ''.$langs->trans("Description").' ';
+print ''.$langs->trans("Status")." \n";
+print ''.$langs->trans("Default")." \n";
+print ''.$langs->trans("ShortInfo").' ';
+print ''.$langs->trans("Preview").' ';
+print " \n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+ foreach (array('','/doc') as $valdir)
+ {
+ $dir = dol_buildpath($reldir."core/modules/holiday".$valdir);
+
+ if (is_dir($dir))
+ {
+ $handle=opendir($dir);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ $filelist[]=$file;
+ }
+ closedir($handle);
+ arsort($filelist);
+
+ foreach($filelist as $file)
+ {
+ if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
+ {
+
+ if (file_exists($dir.'/'.$file))
+ {
+ $name = substr($file, 4, dol_strlen($file) -16);
+ $classname = substr($file, 0, dol_strlen($file) -12);
+
+ require_once $dir.'/'.$file;
+ $module = new $classname($db);
+
+ $modulequalified=1;
+ if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+ if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+
+ if ($modulequalified)
+ {
+ print '';
+ print (empty($module->name)?$name:$module->name);
+ print " \n";
+ if (method_exists($module,'info')) print $module->info($langs);
+ else print $module->description;
+ print ' ';
+
+ // Active
+ if (in_array($name, $def))
+ {
+ print ''."\n";
+ print '';
+ print img_picto($langs->trans("Enabled"),'switch_on');
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+ print ''."\n";
+ print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').' ';
+ print " ";
+ }
+
+ // Defaut
+ print '';
+ if ($conf->global->HOLIDAY_ADDON_PDF == $name)
+ {
+ print img_picto($langs->trans("Default"),'on');
+ }
+ else
+ {
+ print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').' ';
+ }
+ print ' ';
+
+ // Info
+ $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+ $htmltooltip.=' '.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+ if ($module->type == 'pdf')
+ {
+ $htmltooltip.=' '.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+ }
+ $htmltooltip.=''.$langs->trans("FeaturesSupported").': ';
+ $htmltooltip.=' '.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+ $htmltooltip.=' '.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+ $htmltooltip.=' '.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+ $htmltooltip.=' '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+ $htmltooltip.=' '.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+
+
+ print '';
+ print $form->textwithpicto('',$htmltooltip,1,0);
+ print ' ';
+
+ // Preview
+ print '';
+ if ($module->type == 'pdf')
+ {
+ print ''.img_object($langs->trans("Preview"),'contract').' ';
+ }
+ else
+ {
+ print img_object($langs->trans("PreviewNotAvailable"),'generic');
+ }
+ print ' ';
+
+ print " \n";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+print '
';
+print " ";
+
+/*
+ * Other options
+ *
+ */
+
+print '';
+
+dol_fiche_end();
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 62f17d5cb1d..e15e6d0f91f 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -3,6 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2017 Regis Houssin
* Copyright (C) 2016 Juanjo Menent
+ * Copyright (C) 2018 Ferran Marcet
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -79,10 +80,10 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update')
{
- dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
@@ -133,21 +134,24 @@ if ($action == 'update')
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
+ if (GETPOST('THEME_ELDY_USE_CHECKED') == '') dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", '0', 'chaine', 0, '', $conf->entity);
+ else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $_POST["THEME_ELDY_USE_CHECKED"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
- dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0); // Param for all entities
- dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
+
+ dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
+ dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0); // Param for all entities
+ dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
$varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/';
if ($_FILES[$varforimage]["tmp_name"])
@@ -309,8 +313,8 @@ if ($action == 'edit') // Edit
// Firstname/Name
print ''.$langs->trans("FirstnameNamePosition").' ';
- $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
- print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
+ $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
+ print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
print ' ';
print ' ';
print ' ';
@@ -413,7 +417,7 @@ if ($action == 'edit') // Edit
print ''.img_delete($langs->trans("Delete")).' ';
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
print ' ';
- print ' ';
+ print ' ';
}
} else {
print ' ';
@@ -561,7 +565,7 @@ else // Show
print $conf->global->MAIN_LOGIN_BACKGROUND;
if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND))
{
- print ' ';
+ print ' ';
}
else
{
@@ -578,6 +582,6 @@ else // Show
print '';
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index 6542cec1174..2f64793c28b 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -114,7 +114,6 @@ if (empty($reshook))
print '';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index 6776cfb1480..052b2f38988 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -340,5 +340,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php
index 3188bf6e58a..dd85a998383 100644
--- a/htdocs/admin/ldap_contacts.php
+++ b/htdocs/admin/ldap_contacts.php
@@ -318,6 +318,7 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php
index 4ae6ce9ad97..2650fe4fe6e 100644
--- a/htdocs/admin/ldap_groups.php
+++ b/htdocs/admin/ldap_groups.php
@@ -251,5 +251,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php
index 616eb99a8da..2f36f239257 100644
--- a/htdocs/admin/ldap_members.php
+++ b/htdocs/admin/ldap_members.php
@@ -80,9 +80,9 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"),'chaine',0,'',$conf->entity)) $error++;
// Subscriptions
- if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
+ if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT',GETPOST("fieldfirstsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
- if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
+ if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
@@ -442,7 +442,6 @@ if (function_exists("ldap_connect"))
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php
index e45857f2f38..e845fd37adc 100644
--- a/htdocs/admin/ldap_members_types.php
+++ b/htdocs/admin/ldap_members_types.php
@@ -241,5 +241,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php
index 8b11069fc61..513aa63f035 100644
--- a/htdocs/admin/ldap_users.php
+++ b/htdocs/admin/ldap_users.php
@@ -470,5 +470,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index e9389b0271d..f9fe219afef 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -66,11 +66,11 @@ if ($action == 'update')
if (! $error)
{
- dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT", $_POST["MAIN_MAX_DECIMALS_UNIT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT", $_POST["MAIN_MAX_DECIMALS_TOT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN", $_POST["MAIN_MAX_DECIMALS_SHOWN"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT", $_POST["MAIN_MAX_DECIMALS_UNIT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT", $_POST["MAIN_MAX_DECIMALS_TOT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN", $_POST["MAIN_MAX_DECIMALS_SHOWN"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_ROUNDING_RULE_TOT", $_POST["MAIN_ROUNDING_RULE_TOT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_ROUNDING_RULE_TOT", $_POST["MAIN_ROUNDING_RULE_TOT"],'chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -306,7 +306,6 @@ else
*/
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php
index 88ce717f005..91fb9f964e4 100644
--- a/htdocs/admin/livraison.php
+++ b/htdocs/admin/livraison.php
@@ -478,6 +478,7 @@ print '';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php
index 6ccf798bc93..55fe6f10362 100644
--- a/htdocs/admin/livraison_extrafields.php
+++ b/htdocs/admin/livraison_extrafields.php
@@ -87,7 +87,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php
index 431d5c3c170..e70b4f2d09b 100644
--- a/htdocs/admin/livraisondet_extrafields.php
+++ b/htdocs/admin/livraisondet_extrafields.php
@@ -88,7 +88,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -101,7 +101,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -120,6 +120,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php
index 3349ac0056a..419f6efbee9 100644
--- a/htdocs/admin/loan.php
+++ b/htdocs/admin/loan.php
@@ -122,5 +122,6 @@ print "\n";
print '
';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php
index 32fbdd4aeb6..d5b866d9d20 100644
--- a/htdocs/admin/mailing.php
+++ b/htdocs/admin/mailing.php
@@ -152,6 +152,6 @@ print 'entity);
- dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"), 'chaine', 0, '', $conf->entity);
// Send mode parameters
- dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY"), 'chaine', 0, '', $conf->entity);
// Content parameters
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -366,7 +366,7 @@ if ($action == 'edit')
{
$mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:'');
- print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
+ print ' '.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
// SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
{
@@ -386,7 +386,7 @@ if ($action == 'edit')
{
$mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:'');
- print ' '.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
+ print ' '.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
// SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
{
@@ -854,7 +854,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php
index 91826f2be1d..59fc0ade0cd 100644
--- a/htdocs/admin/mails_emailing.php
+++ b/htdocs/admin/mails_emailing.php
@@ -61,12 +61,12 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
if ($action == 'update' && empty($_POST["cancel"]))
{
// Send mode parameters
- dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),'chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@@ -601,7 +601,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index b6268e7fc1e..4914152f680 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -23,7 +23,7 @@
*/
require '../main.inc.php';
-require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@@ -498,7 +498,7 @@ print ''."\n";
if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
- require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
$hidegeneratedfilelistifempty=1;
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index af7d29c0fd6..da6989b41fd 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2004 Benoit Mortier
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2010-2016 Juanjo Menent
@@ -556,7 +556,7 @@ foreach ($fieldsforcontent as $tmpfieldlist)
print ' ';
}
else if ($tmpfieldlist == 'joinfiles') {
- print ' ';
+ print ' ';
}
else
{
@@ -925,6 +925,7 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
@@ -989,7 +990,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print '';
if (! empty($conf->global->MAIN_MULTILANGS))
{
- $selectedlang = $langs->defaultlang;
+ $selectedlang = GETPOSTISSET('langcode','aZ09')?GETPOST('langcode','aZ09'):$langs->defaultlang;
if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]};
print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150');
}
diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php
index 083d78c03e5..09907652df0 100644
--- a/htdocs/admin/menus.php
+++ b/htdocs/admin/menus.php
@@ -64,10 +64,10 @@ if ($action == 'update' && ! $cancel)
{
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
- dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD','alpha'),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD','alpha'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", GETPOST('MAIN_MENUFRONT_STANDARD','alpha'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", GETPOST('MAIN_MENUFRONT_STANDARD','alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE", GETPOST('MAIN_MENUFRONT_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity);
// Define list of menu handlers to initialize
@@ -269,7 +269,6 @@ if ($action != 'edit')
print '';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index cd236d85122..0db2d3cd6d1 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -28,9 +28,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
-
-$langs->load("admin");
-$langs->load('other');
+// Load translation files required by the page
+$langs->loadLangs(array("other","admin"));
if (! $user->admin) accessforbidden();
@@ -89,7 +88,7 @@ if ($action == 'update')
if ($result > 0)
{
$menu->titre=GETPOST('titre', 'alpha');
- $menu->leftmenu=GETPOST('leftmenu', 'alpha');
+ $menu->leftmenu=GETPOST('leftmenu', 'aZ09');
$menu->url=GETPOST('url','alpha');
$menu->langs=GETPOST('langs','alpha');
$menu->position=GETPOST('position','int');
@@ -514,5 +513,6 @@ elseif ($action == 'edit')
print ' ';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php
index c3211fc2d75..9d0178c956d 100644
--- a/htdocs/admin/menus/index.php
+++ b/htdocs/admin/menus/index.php
@@ -27,8 +27,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
-$langs->load("other");
-$langs->load("admin");
+// Load translation files required by the page
+$langs->loadLangs(array("other","admin"));
if (! $user->admin) accessforbidden();
@@ -410,6 +410,6 @@ else
print ' ';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php
index 7789c3fb21c..7b1a73f2f09 100644
--- a/htdocs/admin/menus/other.php
+++ b/htdocs/admin/menus/other.php
@@ -24,9 +24,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-$langs->load("users");
-$langs->load("admin");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("user","other","admin"));
if (! $user->admin) accessforbidden();
@@ -105,6 +104,6 @@ print ' ';
print '';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php
index cf4596ccda2..b5b33be77aa 100644
--- a/htdocs/admin/modulehelp.php
+++ b/htdocs/admin/modulehelp.php
@@ -313,7 +313,9 @@ if ($mode == 'desc')
{
$textexternal.='
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule",$dirofmodule);
if ($objMod->editor_name != 'dolibarr') $textexternal.='
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name);
- if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='
'.$langs->trans("Url").': '.$objMod->editor_url.' ';
+ $editor_url = $objMod->editor_url;
+ if (! preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url;
+ if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='
'.$langs->trans("Url").': '.$objMod->editor_url.' ';
$text.=$textexternal;
$text.='
';
}
@@ -592,7 +594,6 @@ dol_fiche_end();
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index 588bdb856db..89f0f028e1e 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -7,6 +7,7 @@
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Raphaël Doursenaud
+ * Copyright (C) 2018 Nicolas ZABOURI
*
* 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
@@ -55,7 +56,7 @@ $options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int'
$options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0);
$options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0);
$options['search'] = GETPOST('search_keyword', 'alpha');
-$dolistore = new Dolistore();
+$dolistore = new Dolistore(false);
if (! $user->admin)
@@ -597,17 +598,18 @@ if ($mode == 'common')
}
// Print a separator if we change family
- if ($familykey!=$oldfamily)
- {
- if ($oldfamily) print ' ';
+ if ($familykey != $oldfamily) {
+ if ($oldfamily) {
+ print ' ';
+ }
- $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
- print_fiche_titre($familytext, '', '');
+ $familytext = empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
+ print load_fiche_titre($familytext, '', '');
print '';
- print '
'."\n";
+ print ''."\n";
- $atleastoneforfamily=0;
+ $atleastoneforfamily=0;
}
$atleastoneforfamily++;
@@ -637,6 +639,7 @@ if ($mode == 'common')
}
print ''."\n";
+ if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''.++$linenum.' ';
// Picto + Name of module
print ' ';
@@ -669,6 +672,17 @@ if ($mode == 'common')
// Version
print ' ';
print $versiontrans;
+ if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
+ if (!empty($objMod->url_last_version)) {
+ $newversion = getURLContent($objMod->url_last_version);
+ if(isset($newversion['content'])){
+ if (version_compare($newversion['content'], $versiontrans) > 0) {
+ print " ".$newversion['content']." ";
+ }
+ }
+ }
+ }
print " \n";
// Activate/Disable and Setup (2 columns)
@@ -1067,8 +1081,6 @@ if ($mode == 'develop')
dol_fiche_end();
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php
index d4a031a6148..9843c6a4fb0 100644
--- a/htdocs/admin/multicurrency.php
+++ b/htdocs/admin/multicurrency.php
@@ -19,14 +19,11 @@
/**
* \file admin/multicurrency.php
* \ingroup multicurrency
- * \brief This file is an example module setup page
- * Put some comments here
+ * \brief Page to setup multicurrency module
*/
+
// Dolibarr environment
-
require '../main.inc.php';
-
-// Libraries
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
@@ -42,6 +39,8 @@ if (! $user->admin) {
// Parameters
$action = GETPOST('action', 'alpha');
+
+
/*
* Actions
*/
@@ -164,33 +163,30 @@ if ($resql)
* View
*/
+$form=new Form($db);
+
$page_name = "MultiCurrencySetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '' . $langs->trans("BackToModuleList") . ' ';
-print_fiche_titre($langs->trans($page_name), $linkback);
+print load_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = multicurrencyAdminPrepareHead();
dol_fiche_head($head, 'settings', $langs->trans("ModuleSetup"), -1, "multicurrency");
-// Setup page goes here
-$form=new Form($db);
-$var=false;
print '';
print '';
print ''.$langs->trans("Parameters").' '."\n";
-print ' ';
-print ''.$langs->trans("Value").' '."\n";
-
+print ''.$langs->trans("Value").' '."\n";
+print ' ';
print '';
print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE").' ';
-print ' ';
-print '';
+print ' ';
print '';
print ' ';
print ' ';
@@ -200,11 +196,9 @@ print ' ';
print ' ';
-
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").' ';
-print ' ';
-print '';
+print ' ';
print '';
print ' ';
print ' ';
@@ -217,8 +211,7 @@ print ' ';
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_buyPriceInCurrency").' ';
-print ' ';
-print '';
+print ' ';
print '';
print ' ';
print ' ';
@@ -232,8 +225,7 @@ print ' ';
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_modifyRateApplication").' ';
-print ' ';
-print '';
+print ' ';
print '';
print ' ';
print ' ';
@@ -245,16 +237,17 @@ print ' ';
*/
print '
';
+
print ' ';
if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
{
- $var=false;
+ print '';
print '
';
+
print '';
print ''.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize")).' '."\n";
- print ' ';
- print '';
+ print ' ';
print '';
print ' ';
print ' ';
@@ -263,11 +256,9 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print ' ';
-
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_appId").' ';
- print ' ';
- print '';
+ print ' ';
print '';
print ' ';
print ' ';
@@ -279,8 +270,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").' ';
- print ' ';
- print '';
+ print ' ';
print '';
print ' ';
print ' ';
@@ -291,8 +281,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").' ';
- print ' ';
- print '';
+ print ' ';
print '';
print ' ';
print ' ';
@@ -302,35 +291,35 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print ' ';
print '
';
+ print '
';
print ' ';
}
+print '';
print '
';
-
-
+print '
';
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php
index 43782816202..d93421ef6fb 100644
--- a/htdocs/admin/notification.php
+++ b/htdocs/admin/notification.php
@@ -272,7 +272,6 @@ print '";
}
@@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -117,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php
index c75551cf9f0..929e49c4ab3 100644
--- a/htdocs/admin/orderdet_extrafields.php
+++ b/htdocs/admin/orderdet_extrafields.php
@@ -86,7 +86,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php
index 1864fdb557c..4ca9411e105 100644
--- a/htdocs/admin/payment.php
+++ b/htdocs/admin/payment.php
@@ -262,7 +262,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index f988b27c5e6..76b3cf76b57 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -32,11 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
// Load translation files required by the page
-$langs->loadLangs(array('admin', 'languages', 'other'));
-
-$langs->load("companies");
-$langs->load("products");
-$langs->load("members");
+$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members'));
if (! $user->admin) accessforbidden();
@@ -54,29 +50,29 @@ if ($cancel) {
if ($action == 'update')
{
- dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", $_POST["MAIN_TVAINTRA_NOT_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", $_POST["MAIN_TVAINTRA_NOT_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"],'chaine',0,'', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -668,7 +664,6 @@ else // Show
print ' ';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index 50bf939c07f..db4e1f33553 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -218,5 +218,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
-$db->close();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index 6fd40cf2825..c40eca7380e 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -80,6 +80,16 @@ if ($action == "set")
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
+ if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END")=="")
+ {
+ $res = dolibarr_set_const($db, "END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"),'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
+ if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD")=="")
+ {
+ $res = dolibarr_set_const($db, "USTRD", GETPOST("PRELEVEMENT_USTRD"),'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
if (! $error)
{
@@ -221,6 +231,18 @@ print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER'
print '';
print ' ';
+//EntToEnd
+print ''.$langs->trans("END_TO_END").' ';
+print '';
+print ' ';
+print ' ';
+
+//USTRD
+print ''.$langs->trans("USTRD").' ';
+print '';
+print ' ';
+print ' ';
+
print '
';
print ' ';
@@ -511,5 +533,6 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION))
}
*/
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 94b1d1dac67..bc91729829f 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -649,7 +649,6 @@ print "\n";
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php
index 87a89f5d99b..9490a291729 100644
--- a/htdocs/admin/proxy.php
+++ b/htdocs/admin/proxy.php
@@ -205,5 +205,6 @@ print '
';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php
index 4465017bdc6..9205d49deae 100644
--- a/htdocs/admin/receiptprinter.php
+++ b/htdocs/admin/receiptprinter.php
@@ -52,6 +52,12 @@ if (!$mode) $mode='config';
// used in library escpos maybe useful if php doesn't support gzdecode
if (!function_exists('gzdecode')) {
+ /**
+ * Gzdecode
+ *
+ * @param string $data data to deflate
+ * @return string data deflated
+ */
function gzdecode($data)
{
return gzinflate(substr($data,10,-8));
@@ -243,14 +249,14 @@ if ($mode == 'config' && $user->admin)
print "\n";
$ret = $printer->listprinters();
$nbofprinters = count($printer->listprinters);
-
+
if ($ret > 0) {
setEventMessages($printer->error, $printer->errors, 'errors');
} else {
- for ($line=0; $line < $nbofprinters; $line++)
+ for ($line=0; $line < $nbofprinters; $line++)
{
print '';
- if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid)
+ if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid)
{
print ' ';
print ' ';
@@ -285,7 +291,7 @@ if ($mode == 'config' && $user->admin)
}
}
- if ($action!='editprinter')
+ if ($action!='editprinter')
{
if ($nbofprinters > 0)
{
@@ -299,7 +305,7 @@ if ($mode == 'config' && $user->admin)
print ' ';
print " \n";
}
-
+
print '';
print ' ';
$ret = $printer->selectTypePrinter();
@@ -315,7 +321,7 @@ if ($mode == 'config' && $user->admin)
print '';
dol_fiche_end();
-
+
if ($action!='editprinter') {
print '
';
} else {
@@ -324,9 +330,9 @@ if ($mode == 'config' && $user->admin)
print '';
print '';
-
+
dol_fiche_head();
-
+
print $langs->trans("ReceiptPrinterTypeDesc")." \n";
print ''."\n";
print ''.$langs->trans("CONNECTOR_DUMMY").': '.$langs->trans("CONNECTOR_DUMMY_HELP").' ';
@@ -338,7 +344,7 @@ if ($mode == 'config' && $user->admin)
dol_fiche_end();
print '';
-
+
dol_fiche_head();
print $langs->trans("ReceiptPrinterProfileDesc")." \n";
print ''."\n";
@@ -378,7 +384,7 @@ if ($mode == 'template' && $user->admin)
setEventMessages($printer->error, $printer->errors, 'errors');
} else {
$max = count($printer->listprinterstemplates);
- for ($line=0; $line < $max; $line++)
+ for ($line=0; $line < $max; $line++)
{
print '';
if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) {
@@ -423,7 +429,7 @@ if ($mode == 'template' && $user->admin)
print ''.$langs->trans("Description").' ';
print " \n";
$max = count($printer->tags);
- for ($tag=0; $tag < $max; $tag++)
+ for ($tag=0; $tag < $max; $tag++)
{
print '';
print '<'.$printer->tags[$tag].'> '.$langs->trans(strtoupper($printer->tags[$tag])).' ';
@@ -436,18 +442,17 @@ if ($mode == 'template' && $user->admin)
}
// to remove after test
-$object=new stdClass();
-$object->date_time = '2015-11-02 22:30:25';
-$object->id = 1234;
-$object->customer_firstname = 'John';
-$object->customer_lastname = 'Deuf';
-$object->vendor_firstname = 'Jim';
-$object->vendor_lastname = 'Big';
-$object->barcode = '3700123862396';
+// $object=new stdClass();
+// $object->date_time = '2015-11-02 22:30:25';
+// $object->id = 1234;
+// $object->customer_firstname = 'John';
+// $object->customer_lastname = 'Deuf';
+// $object->vendor_firstname = 'Jim';
+// $object->vendor_lastname = 'Big';
+// $object->barcode = '3700123862396';
//$printer->sendToPrinter($object, 1, 16);
//setEventMessages($printer->error, $printer->errors, 'errors');
+// End of page
llxFooter();
-
$db->close();
-
diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php
index e8f8bdba204..566e57e587b 100644
--- a/htdocs/admin/resource.php
+++ b/htdocs/admin/resource.php
@@ -137,6 +137,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php
index 8193d146aaa..b8ea860ac25 100644
--- a/htdocs/admin/resource_extrafields.php
+++ b/htdocs/admin/resource_extrafields.php
@@ -84,7 +84,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -97,7 +97,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -116,6 +116,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php
index 6c5281173c3..a68a4bda5a6 100644
--- a/htdocs/admin/salaries.php
+++ b/htdocs/admin/salaries.php
@@ -75,7 +75,7 @@ if ($action == 'update')
llxHeader('',$langs->trans('SalariesSetup'));
$form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
$linkback=''.$langs->trans("BackToModuleList").' ';
print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup');
@@ -127,5 +127,6 @@ print '';
-
// Form to test upload
print '
';
$formfile=new FormFile($db);
@@ -188,5 +187,6 @@ $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestF
$filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
$formfile->list_of_documents($filearray, null, 'admin_temp', '');
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php
index 6503ab10f77..0e3da947fa8 100644
--- a/htdocs/admin/security_other.php
+++ b/htdocs/admin/security_other.php
@@ -206,6 +206,6 @@ print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php
index db1cb20b5e3..45071117c89 100644
--- a/htdocs/admin/sms.php
+++ b/htdocs/admin/sms.php
@@ -48,12 +48,12 @@ $action=GETPOST('action','aZ09');
if ($action == 'update' && empty($_POST["cancel"]))
{
- dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", $_POST["MAIN_DISABLE_ALL_SMS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", $_POST["MAIN_DISABLE_ALL_SMS"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_SMS_SENDMODE", $_POST["MAIN_SMS_SENDMODE"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SMS_SENDMODE", $_POST["MAIN_SMS_SENDMODE"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", $_POST["MAIN_MAIL_SMS_FROM"],'chaine',0,'',$conf->entity);
- //dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", $_POST["MAIN_MAIL_SMS_FROM"], 'chaine', 0, '', $conf->entity);
+ //dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"], 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -169,21 +169,21 @@ if ($action == 'edit')
print '
';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- // Disable
+ // Disable
print ''.$langs->trans("MAIN_DISABLE_ALL_SMS").' ';
print $form->selectyesno('MAIN_DISABLE_ALL_SMS',$conf->global->MAIN_DISABLE_ALL_SMS,1);
print ' ';
- // Separator
+ // Separator
print ' ';
- // Method
+ // Method
print ''.$langs->trans("MAIN_SMS_SENDMODE").' ';
if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE',$listofmethods,$conf->global->MAIN_SMS_SENDMODE,1);
else print ''.$langs->trans("None").' ';
print ' ';
- // From
+ // From
print ''.$langs->trans("MAIN_MAIL_SMS_FROM",$langs->transnoentities("Undefined")).' ';
print ' ';
@@ -213,20 +213,20 @@ else
print '';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- // Disable
+ // Disable
print ''.$langs->trans("MAIN_DISABLE_ALL_SMS").' '.yn($conf->global->MAIN_DISABLE_ALL_SMS).' ';
- // Separator
+ // Separator
print ' ';
- // Method
+ // Method
print ''.$langs->trans("MAIN_SMS_SENDMODE").' ';
$text=$listofmethods[$conf->global->MAIN_SMS_SENDMODE];
if (empty($text)) $text=$langs->trans("Undefined").' '.img_warning();
print $text;
print ' ';
- // From
+ // From
print ''.$langs->trans("MAIN_MAIL_SMS_FROM",$langs->transnoentities("Undefined")).' ';
print ''.$conf->global->MAIN_MAIL_SMS_FROM;
if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && ! isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone"));
@@ -331,7 +331,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php
index b9892fdf2a9..d179c66d58d 100644
--- a/htdocs/admin/spip.php
+++ b/htdocs/admin/spip.php
@@ -163,6 +163,6 @@ else
dol_fiche_end();
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index e1098ef262d..858422c598c 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -160,7 +160,7 @@ print ' ';
print '';
print '';
print " ".$langs->trans("RuleForStockManagementDecrease")." \n";
-print " \n";
+print " \n";
print ' '."\n";
$found=0;
@@ -262,7 +262,7 @@ print ' ';
print '';
print '';
print " ".$langs->trans("RuleForStockManagementIncrease")." \n";
-print " \n";
+print " \n";
print ' '."\n";
$found=0;
@@ -341,7 +341,7 @@ print ' ';
print '';
print '';
print " ".$langs->trans("RuleForStockAvailability")." \n";
-print " \n";
+print " \n";
print ' '."\n";
@@ -373,7 +373,7 @@ if($conf->invoice->enabled)
print "\n";
}
-if($conf->order->enabled)
+if($conf->order->enabled)
{
print '';
print ''.$langs->trans("StockMustBeEnoughForOrder").' ';
@@ -388,7 +388,7 @@ if($conf->order->enabled)
print " \n";
}
-if($conf->expedition->enabled)
+if($conf->expedition->enabled)
{
print '';
print ''.$langs->trans("StockMustBeEnoughForShipment").' ';
@@ -416,7 +416,7 @@ if ($virtualdiffersfromphysical)
print '';
print '';
print " ".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))." \n";
- print " \n";
+ print " \n";
print ' '."\n";
print '';
@@ -439,12 +439,12 @@ print '';
print '';
print " ".$langs->trans("Other")." \n";
-print " \n";
+print " \n";
print ' '."\n";
print '';
print ''.$langs->trans("UserWarehouseAutoCreate").' ';
-print '';
+print ' ';
print "";
print ' ';
print " ";
@@ -456,7 +456,8 @@ print " \n";
print '';
print '';
-print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")).' ';
+print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc"));
+print '';
print '';
print "";
print ' ';
@@ -502,7 +503,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '';
print ''.$langs->trans("Inventory").' '."\n";
print ' ';
- print ' '."\n";
+ print ' '."\n";
// Example with a yes / no select
print ' ';
@@ -566,7 +567,6 @@ if ($conf->global->PRODUIT_SOUSPRODUITS)
}
*/
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php
index 75a917dd185..367d1fe0d36 100644
--- a/htdocs/admin/supplier_invoice.php
+++ b/htdocs/admin/supplier_invoice.php
@@ -516,7 +516,6 @@ print " \n";
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index 695d25a963c..72050867dfa 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -589,7 +589,6 @@ print " \n";
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php
index c1f3a7cb25d..55fb311ccda 100644
--- a/htdocs/admin/supplier_payment.php
+++ b/htdocs/admin/supplier_payment.php
@@ -430,7 +430,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 99069447e81..eeb148e9d99 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -582,6 +582,7 @@ print "\n";
print "\n ".$langs->trans("PathDirectory")." \n ".$conf->supplier_proposal->dir_output." \n \n";
print "
\n ";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php
index 7e913772e2c..bbda698a778 100644
--- a/htdocs/admin/supplierinvoice_extrafields.php
+++ b/htdocs/admin/supplierinvoice_extrafields.php
@@ -4,7 +4,7 @@
* Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2012 Regis Houssin
* Copyright (C) 2012 Florian Henry
- * Copyright (C) 2013 Philippe Grand
+ * Copyright (C) 2013-2018 Philippe Grand
* Copyright (C) 2013 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
@@ -32,17 +32,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
-$langs->load("orders");
+$langs->loadLangs(array("admin", "other", "bills", "orders", "suppliers"));
if (!$user->admin)
accessforbidden();
-$langs->load("admin");
-$langs->load("other");
-$langs->load("bills");
-$langs->load("orders");
-$langs->load("suppliers");
-
$extrafields = new ExtraFields($db);
$form = new Form($db);
@@ -91,7 +85,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -104,7 +98,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -123,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php
index d8156d54779..cdf128871fd 100644
--- a/htdocs/admin/supplierinvoicedet_extrafields.php
+++ b/htdocs/admin/supplierinvoicedet_extrafields.php
@@ -87,7 +87,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php
index 30cf4d983e4..640b6375c57 100644
--- a/htdocs/admin/supplierorder_extrafields.php
+++ b/htdocs/admin/supplierorder_extrafields.php
@@ -85,7 +85,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -117,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php
index 85106bf84f0..65fe0537ba7 100644
--- a/htdocs/admin/supplierorderdet_extrafields.php
+++ b/htdocs/admin/supplierorderdet_extrafields.php
@@ -86,7 +86,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php
index 45dc91a8b95..e163fc83de5 100644
--- a/htdocs/admin/syslog.php
+++ b/htdocs/admin/syslog.php
@@ -302,6 +302,6 @@ if(! empty($conf->loghandlers['mod_syslog_file']) && ! empty($conf->cron->enable
print '
';
print "\n";
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php
index 61780d51386..ba61203191a 100644
--- a/htdocs/admin/system/about.php
+++ b/htdocs/admin/system/about.php
@@ -28,10 +28,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-$langs->load("admin");
-$langs->load("help");
-$langs->load("members");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("help","members","other","admin"));
$action=GETPOST('action','alpha');
@@ -196,7 +194,7 @@ if ($showpromotemessage)
{
print ' ';
print ' ';
-
+
if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0))
{
print $langs->trans("TitleExampleForMajorRelease").': ';
@@ -214,7 +212,6 @@ if ($showpromotemessage)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php
index 4f2a53de88d..9df49489e34 100644
--- a/htdocs/admin/system/browser.php
+++ b/htdocs/admin/system/browser.php
@@ -26,9 +26,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
@@ -66,7 +65,6 @@ print '
';
print '';
print ' ';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php
index 82e8481c2dd..d510cc07773 100644
--- a/htdocs/admin/system/constall.php
+++ b/htdocs/admin/system/constall.php
@@ -24,9 +24,8 @@
require '../../main.inc.php';
-$langs->load("admin");
-$langs->load("user");
-$langs->load("install");
+// Load translation files required by the page
+$langs->loadLangs(array("install","user","admin"));
if (!$user->admin)
@@ -249,7 +248,6 @@ if ($resql)
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php
index 556961cb565..17d72edf20a 100644
--- a/htdocs/admin/system/database-tables.php
+++ b/htdocs/admin/system/database-tables.php
@@ -212,5 +212,6 @@ else
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php
index 45ce3c087e6..d5a7bbcdbfd 100644
--- a/htdocs/admin/system/database.php
+++ b/htdocs/admin/system/database.php
@@ -126,6 +126,6 @@ else
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php
index cef493c95f8..392c083c382 100644
--- a/htdocs/admin/system/dbtable.php
+++ b/htdocs/admin/system/dbtable.php
@@ -138,6 +138,6 @@ else
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index c0a1c610fe6..9c2ee62565d 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -29,9 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
$action=GETPOST('action','alpha');
@@ -157,7 +156,7 @@ $i=0;
foreach($_SESSION as $key => $val)
{
if ($i > 0) print ', ';
- print $key.' => '.$val;
+ print $key.' => '.dol_escape_htmltag($val);
$i++;
}
print '
'."\n";
@@ -453,7 +452,6 @@ if ($resql)
print '
';
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php
index 3cef158c2ea..0418830cce8 100644
--- a/htdocs/admin/system/filecheck.php
+++ b/htdocs/admin/system/filecheck.php
@@ -366,11 +366,11 @@ if (! $error && $xml)
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
{
- setEventMessage($langs->trans("FileIntegrityIsStrictlyConformedWithReference"));
+ setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
}
else
{
- setEventMessage($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), 'warnings');
+ setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
}
}
else
@@ -422,7 +422,7 @@ if (! $error && $xml)
$outcurrentchecksum = ''.$checksumget.' ';
}
- print_fiche_titre($langs->trans("GlobalChecksum")).' ';
+ print load_fiche_titre($langs->trans("GlobalChecksum")).' ';
print $langs->trans("ExpectedChecksum").' = '. $outexpectedchecksum .' ';
print $langs->trans("CurrentChecksum").' = '. $outcurrentchecksum;
@@ -433,12 +433,8 @@ if (! $error && $xml)
print $out;
}
-
-
-
+// End of page
llxFooter();
-
$db->close();
exit($error);
-
diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php
index 3d473640618..cf79ae910b3 100644
--- a/htdocs/admin/system/index.php
+++ b/htdocs/admin/system/index.php
@@ -25,9 +25,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-$langs->load("admin");
-$langs->load("user");
-$langs->load("install");
+// Load translation files required by the page
+$langs->loadLangs(array("admin", "user", "install"));
if (! $user->admin) accessforbidden();
@@ -106,7 +105,7 @@ print ' ';
print '';
print "".$langs->trans("Browser")." \n";
print "".$langs->trans("UserAgent")." " .$_SERVER["HTTP_USER_AGENT"]." \n";
-print "".$langs->trans("Smartphone")." ".(empty($conf->browser->phone)?$langs->trans("No"):$conf->browser->phone)." \n";
+print "".$langs->trans("Smartphone")." ".(($conf->browser->layout != 'phone')?$langs->trans("No"):$langs->trans("Yes"))." \n";
print '
';
print ' ';
@@ -114,6 +113,6 @@ print ' ';
//print " \n";
print info_admin($langs->trans("SystemInfoDesc")).' ';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php
index 4a6967089e2..c70ad1b7fba 100644
--- a/htdocs/admin/system/modules.php
+++ b/htdocs/admin/system/modules.php
@@ -25,9 +25,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
@@ -79,17 +78,17 @@ foreach($modulesdir as $dir)
{
try {
$objMod = new $modName($db);
-
+
$modules[$objMod->numero]=$objMod;
$modules_names[$objMod->numero]=$objMod->name;
$modules_files[$objMod->numero]=$file;
$modules_fullpath[$file]=$dir.$file;
$picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
- }
+ }
catch(Exception $e)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
- }
+ }
}
else
{
@@ -159,5 +158,6 @@ foreach($rights_ids as $right_id)
$old = $right_id;
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php
index 01d48f2444d..251025a4c9e 100644
--- a/htdocs/admin/system/os.php
+++ b/htdocs/admin/system/os.php
@@ -49,6 +49,6 @@ $osversion=version_os();
print "".$langs->trans("Version")." ".$osversion." \n";
print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php
index 1e757b72f63..d69723f1299 100644
--- a/htdocs/admin/system/perf.php
+++ b/htdocs/admin/system/perf.php
@@ -26,9 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
@@ -491,7 +490,6 @@ print ''.$langs->trans("DatabaseStatistics").' : ';
print ' ';
*/
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php
index 8664a28b28a..aa502cde421 100644
--- a/htdocs/admin/system/phpinfo.php
+++ b/htdocs/admin/system/phpinfo.php
@@ -116,7 +116,6 @@ foreach($phparray as $key => $value)
print ' ';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php
index 53eaeec085f..b582e61619b 100644
--- a/htdocs/admin/system/xcache.php
+++ b/htdocs/admin/system/xcache.php
@@ -76,6 +76,6 @@ if ($action == 'clear')
}
*/
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php
index 7c4bf64909f..304f9b79bd0 100644
--- a/htdocs/admin/taxes.php
+++ b/htdocs/admin/taxes.php
@@ -273,6 +273,6 @@ if (! empty($conf->accounting->enabled))
print ''.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).' ';
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php
index c6f5e49ff01..5cf72b302c9 100644
--- a/htdocs/admin/ticket.php
+++ b/htdocs/admin/ticket.php
@@ -54,10 +54,13 @@ if ($action == 'updateMask') {
$error++;
}
- if (!$error) {
- setEventMessage($langs->trans("SetupSaved"));
- } else {
- setEventMessage($langs->trans("Error"), 'errors');
+ if (!$error)
+ {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'setmod') {
// TODO Verifier si module numerotation choisi peut etre active
@@ -67,92 +70,92 @@ if ($action == 'updateMask') {
} elseif ($action == 'setvar') {
include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
- $notification_email = GETPOST('TICKETS_NOTIFICATION_EMAIL_FROM', 'alpha');
+ $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
if (!empty($notification_email)) {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
// altairis : differentiate notification email FROM and TO
- $notification_email_to = GETPOST('TICKETS_NOTIFICATION_EMAIL_TO', 'alpha');
+ $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
if (!empty($notification_email_to)) {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $mail_new_ticket = GETPOST('TICKETS_MESSAGE_MAIL_NEW', 'alpha');
+ $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha');
if (!empty($mail_new_ticket)) {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $mail_intro = GETPOST('TICKETS_MESSAGE_MAIL_INTRO', 'alpha');
+ $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha');
if (!empty($mail_intro)) {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $mail_signature = GETPOST('TICKETS_MESSAGE_MAIL_SIGNATURE', 'alpha');
+ $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $url_interface = GETPOST('TICKETS_URL_PUBLIC_INTERFACE', 'alpha');
+ $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $topic_interface = GETPOST('TICKETS_PUBLIC_INTERFACE_TOPIC', 'alpha');
+ $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $text_home = GETPOST('TICKETS_PUBLIC_TEXT_HOME', 'alpha');
+ $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $text_help = GETPOST('TICKETS_PUBLIC_TEXT_HELP_MESSAGE', 'alpha');
+ $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha');
if (!empty($text_help)) {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
@@ -160,34 +163,34 @@ if ($action == 'updateMask') {
}
if ($action == 'setvarother') {
- $param_enable_public_interface = GETPOST('TICKETS_ENABLE_PUBLIC_INTERFACE', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity);
+ $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_must_exists = GETPOST('TICKETS_EMAIL_MUST_EXISTS', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
+ $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_disable_email = GETPOST('TICKETS_DISABLE_ALL_MAILS', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
+ $param_disable_email = GETPOST('TICKET_DISABLE_ALL_MAILS', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_activate_log_by_email = GETPOST('TICKETS_ACTIVATE_LOG_BY_EMAIL', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity);
+ $param_activate_log_by_email = GETPOST('TICKET_ACTIVATE_LOG_BY_EMAIL', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
- $param_show_module_logo = GETPOST('TICKETS_SHOW_MODULE_LOGO', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
+ $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
@@ -195,21 +198,21 @@ if ($action == 'setvarother') {
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
- $param_notification_also_main_addressemail = GETPOST('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
+ $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
- $param_limit_view = GETPOST('TICKETS_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
+ $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_auto_assign = GETPOST('TICKETS_AUTO_ASSIGN_USER_CREATE', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
+ $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
@@ -358,10 +361,10 @@ print '';
print '' . $langs->trans("TicketsActivatePublicInterface") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_ENABLE_PUBLIC_INTERFACE');
+ print ajax_constantonoff('TICKET_ENABLE_PUBLIC_INTERFACE');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKETS_ENABLE_PUBLIC_INTERFACE);
+ print $form->selectarray("TICKET_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKET_ENABLE_PUBLIC_INTERFACE);
}
print ' ';
print '';
@@ -373,10 +376,10 @@ print ' ';
print '' . $langs->trans("TicketsEmailMustExist") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_EMAIL_MUST_EXISTS');
+ print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKETS_EMAIL_MUST_EXISTS);
+ print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS);
}
print ' ';
print '';
@@ -390,10 +393,10 @@ print ' ';
print '' . $langs->trans("TicketsShowModuleLogo") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_SHOW_MODULE_LOGO');
+ print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKETS_SHOW_MODULE_LOGO);
+ print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO);
}
print ' ';
print '';
@@ -406,10 +409,10 @@ print ' ';
print '' . $langs->trans("TicketsShowCompanyLogo") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_SHOW_COMPANY_LOGO');
+ print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKETS_SHOW_COMPANY_LOGO);
+ print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO);
}
print ' ';
print '';
@@ -426,10 +429,10 @@ print '';
print '' . $langs->trans("TicketsDisableEmail") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_DISABLE_ALL_MAILS');
+ print ajax_constantonoff('TICKET_DISABLE_ALL_MAILS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_DISABLE_ALL_MAILS", $arrval, $conf->global->TICKETS_DISABLE_ALL_MAILS);
+ print $form->selectarray("TICKET_DISABLE_ALL_MAILS", $arrval, $conf->global->TICKET_DISABLE_ALL_MAILS);
}
print ' ';
print '';
@@ -441,10 +444,10 @@ print ' ';
print '' . $langs->trans("TicketsLogEnableEmail") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_ACTIVATE_LOG_BY_EMAIL');
+ print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKETS_ACTIVATE_LOG_BY_EMAIL);
+ print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL);
}
print ' ';
print '';
@@ -458,10 +461,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print ' ' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS');
+ print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS);
+ print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
}
print ' ';
print '';
@@ -474,10 +477,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print ' ' . $langs->trans("TicketsLimitViewAssignedOnly") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_LIMIT_VIEW_ASSIGNED_ONLY');
+ print ajax_constantonoff('TICKET_LIMIT_VIEW_ASSIGNED_ONLY');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_LIMIT_VIEW_ASSIGNED_ONLY", $arrval, $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY);
+ print $form->selectarray("TICKET_LIMIT_VIEW_ASSIGNED_ONLY", $arrval, $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY);
}
print ' ';
print '';
@@ -494,10 +497,10 @@ if (!$conf->use_javascript_ajax) {
print ' ' . $langs->trans("TicketsAutoAssignTicket") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_AUTO_ASSIGN_USER_CREATE');
+ print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKETS_AUTO_ASSIGN_USER_CREATE);
+ print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
}
print ' ';
print '';
@@ -533,7 +536,7 @@ if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
// Email d'envoi des notifications
print ' ' . $langs->trans("TicketEmailNotificationFrom") . ' ';
print '';
-print ' ';
+print ' ';
print '';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
print ' ';
@@ -542,18 +545,18 @@ print ' ';
// Email de réception des notifications
print '' . $langs->trans("TicketEmailNotificationTo") . ' ';
print '';
-print ' ';
+print ' ';
print '';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
print ' ';
print ' ';
// Texte de création d'un ticket
-$mail_mesg_new = $conf->global->TICKETS_MESSAGE_MAIL_NEW ? $conf->global->TICKETS_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody');
+$mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody');
print '' . $langs->trans("TicketNewEmailBodyLabel") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -561,11 +564,11 @@ print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help
print ' ';
// Texte d'introduction
-$mail_intro = $conf->global->TICKETS_MESSAGE_MAIL_INTRO ? $conf->global->TICKETS_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
+$mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
print '' . $langs->trans("TicketMessageMailIntroLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -573,11 +576,11 @@ print $form->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"),
print ' ';
// Texte de signature
-$mail_signature = $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText');
+$mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText');
print '' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -589,31 +592,31 @@ print ' ' . $langs->trans("PublicInterface") . ' ';
print " \n";
// Url public interface
-$url_interface = $conf->global->TICKETS_URL_PUBLIC_INTERFACE;
+$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE;
print '' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . '';
print ' ';
-print ' ';
+print ' ';
print '';
print '';
print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
print ' ';
// Interface topic
-$url_interface = $conf->global->TICKETS_PUBLIC_INTERFACE_TOPIC;
+$url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC;
print '' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . '';
print ' ';
-print ' ';
+print ' ';
print '';
print '';
print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help');
print ' ';
// Texte d'accueil homepage
-$public_text_home = $conf->global->TICKETS_PUBLIC_TEXT_HOME ? $conf->global->TICKETS_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome');
+$public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome');
print '' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -621,11 +624,11 @@ print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpA
print ' ';
// Texte d'aide à la saisie du message
-$public_text_help_message = $conf->global->TICKETS_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKETS_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe');
+$public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe');
print '' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -638,6 +641,6 @@ print ' ';
print '
';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php
index 0687a33c52b..6fa70808ec8 100644
--- a/htdocs/admin/ticket_extrafields.php
+++ b/htdocs/admin/ticket_extrafields.php
@@ -16,9 +16,9 @@
*/
/**
- * \file ticket/admin/ticket_extrafields.php
- * \ingroup ticket
- * \brief Page to setup extra fields of ticket
+ * \file admin/ticket_extrafields.php
+ * \ingroup ticket
+ * \brief Page to setup extra fields of ticket
*/
require '../main.inc.php';
@@ -109,6 +109,6 @@ if ($action == 'edit' && !empty($attrname)) {
include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index 1c985e23090..c9ef19dae98 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -522,6 +522,6 @@ print $langs->trans("BackupDescX").' ';
close();
diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php
index f390c192159..9dc3deec5ac 100644
--- a/htdocs/admin/tools/dolibarr_import.php
+++ b/htdocs/admin/tools/dolibarr_import.php
@@ -24,8 +24,8 @@
require '../../main.inc.php';
-$langs->load("admin");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("other","admin"));
if (! $user->admin)
accessforbidden();
@@ -212,6 +212,6 @@ else if (in_array($type, array('pgsql')))
close();
diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php
index d3253c02514..a3205c11a27 100644
--- a/htdocs/admin/tools/eaccelerator.php
+++ b/htdocs/admin/tools/eaccelerator.php
@@ -181,7 +181,6 @@ function create_script_table($list)
print ' ';
}
print '
';
-
}
/**
@@ -335,7 +334,6 @@ if (function_exists('eaccelerator_get')) {
print " ";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php
index 98a490550ca..aed25ae45a3 100644
--- a/htdocs/admin/tools/index.php
+++ b/htdocs/admin/tools/index.php
@@ -24,8 +24,8 @@
require '../../main.inc.php';
-$langs->load("admin");
-$langs->load("companies");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","admin"));
if (! $user->admin)
accessforbidden();
@@ -56,6 +56,6 @@ print ' ';
//print '';
print '
'; // For a reason I don't know, the div class="center does not works, we must keep the
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index 48d3ef57fd5..9afe7c5fcb3 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2004-2017 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2015 Bahfir Abbes
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,10 +41,8 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
-$langs->load("admin");
-$langs->load("companies");
-$langs->load("users");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","admin","users","other"));
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
@@ -237,7 +236,7 @@ if ($result)
// Lignes des champs de filtres
print '';
- print ''.$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).$form->select_date($date_end,'date_end',0,0,0,'',1,0,1).' ';
+ print ''.$form->selectDate($date_start,'date_start',0,0,0,'',1,0).$form->selectDate($date_end,'date_end',0,0,0,'',1,0).' ';
print '';
print ' ';
@@ -339,6 +338,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php
index 70b0987732b..b1732e0883b 100644
--- a/htdocs/admin/tools/listsessions.php
+++ b/htdocs/admin/tools/listsessions.php
@@ -25,7 +25,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-$langs->load("install");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","install","users","other"));
if (! $user->admin)
accessforbidden();
@@ -40,10 +41,6 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
-$langs->load("companies");
-$langs->load("users");
-$langs->load("other");
-
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
@@ -208,5 +205,6 @@ print '';
print ' ';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php
index f415ed1692c..097fc507240 100644
--- a/htdocs/admin/tools/purge.php
+++ b/htdocs/admin/tools/purge.php
@@ -119,7 +119,6 @@ if (preg_match('/^confirm/i',$choice))
print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php
index d0802d6b473..1ec7c98552e 100644
--- a/htdocs/admin/tools/update.php
+++ b/htdocs/admin/tools/update.php
@@ -27,8 +27,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php';
-$langs->load("admin");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("admin","other"));
$action=GETPOST('action','alpha');
@@ -76,7 +76,7 @@ print $langs->trans("CurrentVersion").' : '.DOL_VERSION.' ';
if (function_exists('curl_init'))
{
$conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10;
-
+
if ($action == 'getlastversion')
{
if ($sfurl)
@@ -95,7 +95,7 @@ if (function_exists('curl_init'))
}
$i++;
}
-
+
// Show version
print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .' ';
}
@@ -142,7 +142,6 @@ print ' ';
print $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"));
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index 55a407c3e61..4c215e9ae52 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -40,7 +40,7 @@ $transkey=GETPOST('transkey','alpha');
$transvalue=GETPOST('transvalue','alpha');
-$mode = GETPOST('mode')?GETPOST('mode'):'overwrite';
+$mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'overwrite';
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
@@ -584,6 +584,6 @@ if (! empty($langcode))
dol_set_focus('#transvalue');
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php
index 1a1893e2eb0..cd2f33b4cb0 100644
--- a/htdocs/admin/triggers.php
+++ b/htdocs/admin/triggers.php
@@ -84,6 +84,6 @@ foreach ($triggers as $trigger)
print '';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php
index f888c8410bb..2cf8fc5b6f3 100644
--- a/htdocs/admin/user.php
+++ b/htdocs/admin/user.php
@@ -337,5 +337,6 @@ print " ";
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php
index 28f1ad6af2f..c1b55dcec6a 100644
--- a/htdocs/admin/usergroup.php
+++ b/htdocs/admin/usergroup.php
@@ -282,5 +282,6 @@ print " ";
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php
index 80144f93c1f..fcdeee79249 100644
--- a/htdocs/admin/website.php
+++ b/htdocs/admin/website.php
@@ -322,10 +322,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($website->id > 0)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
- $result = $db->query($sql);
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website ='".$rowid."'";
+ $result = $db->query($sql);
- $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
+ $result = $db->query($sql);
+
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object ='".$rowid."'";
+ $result = $db->query($sql);
+
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql);
if (! $result)
{
@@ -640,9 +646,7 @@ if ($id)
dol_fiche_end();
-//print ' ';
-
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php
index c688da0e550..9d724b86390 100644
--- a/htdocs/admin/website_options.php
+++ b/htdocs/admin/website_options.php
@@ -143,9 +143,8 @@ else
dol_fiche_end();
-//print ' ';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php
index da87cfd32c9..24a39ce827a 100644
--- a/htdocs/admin/workflow.php
+++ b/htdocs/admin/workflow.php
@@ -39,7 +39,7 @@ $action = GETPOST('action', 'alpha');
*/
if (preg_match('/set(.*)/',$action,$reg))
{
- if (! dolibarr_set_const($db, $reg[1], 1, 'chaine', 0, '', $conf->entity) > 0)
+ if (! dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0)
{
dol_print_error($db);
}
@@ -75,14 +75,12 @@ $workflowcodes=array(
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
'separator1'=>array('family'=>'separator', 'position'=>25),
- // Automatic classification proposal
+ // Automatic classification of proposal
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal','warning'=>''),
'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal','warning'=>''),
- // Automatic classification invoice
+ // Automatic classification of order
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
- // For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card.
- 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''),
- //Moved as hidden feature: 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>42, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''),
+ 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card.
'separator2'=>array('family'=>'separator', 'position'=>50),
// Automatic classification supplier proposal
'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''),
@@ -189,7 +187,6 @@ if ($nbqualified == 0)
}
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 92391a14dc0..6ddb4dae1b3 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -65,6 +65,8 @@ class DolibarrApi
$this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect);
$this->r->setAPIVersion(1);
+ //$this->r->setSupportedFormats('json');
+ //$this->r->setSupportedFormats('jsonFormat');
}
/**
@@ -92,10 +94,12 @@ class DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
// Remove $db object property for object
unset($object->db);
+ unset($object->isextrafieldmanaged);
unset($object->ismultientitymanaged);
unset($object->restrictiononfksoc);
@@ -215,9 +219,11 @@ class DolibarrApi
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
+ * @return bool
* @throws RestException
*/
- static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') {
+ static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
+ {
// Features/modules to check
$featuresarray = array($resource);
@@ -265,6 +271,7 @@ class DolibarrApi
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to forge a SQL criteria
*
@@ -273,6 +280,7 @@ class DolibarrApi
*/
static function _forge_criteria_callback($matches)
{
+ // phpcs:enable
global $db;
//dol_syslog("Convert matches ".$matches[1]);
diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php
index d067d6e2ad6..e453bd331c2 100644
--- a/htdocs/api/class/api_access.class.php
+++ b/htdocs/api/class/api_access.class.php
@@ -59,8 +59,7 @@ class DolibarrApiAccess implements iAuthenticate
*/
public static $user = '';
- // @codingStandardsIgnoreStart
-
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName
/**
* Check access
*
@@ -69,6 +68,7 @@ class DolibarrApiAccess implements iAuthenticate
*/
public function __isAllowed()
{
+ // phpcs:enable
global $conf, $db;
$login = '';
@@ -166,6 +166,7 @@ class DolibarrApiAccess implements iAuthenticate
return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic
@@ -174,9 +175,9 @@ class DolibarrApiAccess implements iAuthenticate
*/
public function __getWWWAuthenticateString()
{
+ // phpcs:enable
return '';
}
- // @codingStandardsIgnoreEnd
/**
* Verify access
@@ -196,6 +197,5 @@ class DolibarrApiAccess implements iAuthenticate
return $requires
? static::$role == 'admin' || in_array(static::$role, (array) $requires)
: true;
-
}
}
diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php
index 07f124741fe..66c293f2cb0 100644
--- a/htdocs/api/class/api_documents.class.php
+++ b/htdocs/api/class/api_documents.class.php
@@ -356,6 +356,22 @@ class Documents extends DolibarrApi
$upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice');
}
+ else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event')
+ {
+ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+
+ if (!DolibarrApiAccess::$user->rights->agenda->myactions->read && !DolibarrApiAccess::$user->rights->agenda->allactions->read) {
+ throw new RestException(401);
+ }
+
+ $object = new ActionComm($this->db);
+ $result=$object->fetch($id, $ref);
+ if ( ! $result ) {
+ throw new RestException(404, 'Event not found');
+ }
+
+ $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
+ }
else
{
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php
index 56808819b3f..86d1cfff87c 100644
--- a/htdocs/api/class/api_login.class.php
+++ b/htdocs/api/class/api_login.class.php
@@ -26,7 +26,11 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
class Login
{
- function __construct() {
+ /**
+ * Constructor of the class
+ */
+ function __construct()
+ {
global $db;
$this->db = $db;
}
@@ -51,7 +55,8 @@ class Login
* @url GET /
* @url POST /
*/
- public function index($login, $password, $entity='', $reset=0) {
+ public function index($login, $password, $entity='', $reset=0)
+ {
global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index ef2b4c8bb6d..9389e2ff5ed 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -1,8 +1,8 @@
* Copyright (C) 2016 Laurent Destailleur
- * Copyright (C) 2017 Regis Houssin
- * Copyright (C) 2017 Neil Orley
+ * Copyright (C) 2017 Regis Houssin
+ * Copyright (C) 2017 Neil Orley
*
*
* This program is free software; you can redistribute it and/or modify
@@ -188,6 +188,7 @@ class Setup extends DolibarrApi
* @param int $id ID of country
* @param string $lang Code of the language the name of the
* country must be translated to
+ * @return array Array of cleaned object properties
*
* @url GET dictionary/countries/{id}
*
@@ -293,6 +294,7 @@ class Setup extends DolibarrApi
* @param Ccountry $country Country
* @param string $lang Code of the language the name of the
* country must be translated to
+ * @return void
*/
private function translateLabel($country, $lang)
{
@@ -863,11 +865,11 @@ class Setup extends DolibarrApi
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
{
- //setEventMessage($langs->trans("FileIntegrityIsStrictlyConformedWithReference"));
+ //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
}
else
{
- //setEventMessage($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), 'warnings');
+ //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
}
}
else
@@ -916,5 +918,4 @@ class Setup extends DolibarrApi
return array('resultcode'=>$resultcode, 'resultcomment'=>$resultcomment, 'expectedchecksum'=> $outexpectedchecksum, 'currentchecksum'=> $outcurrentchecksum, 'out'=>$out);
}
-
}
diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php
index ea61731b51a..3ade4ea51b8 100644
--- a/htdocs/api/class/api_status.class.php
+++ b/htdocs/api/class/api_status.class.php
@@ -26,18 +26,21 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
*/
class Status
{
- /**
+ /**
* Get status (Dolibarr version)
- */
- function index() {
- global $conf;
+ *
+ * @return array
+ */
+ function index()
+ {
+ global $conf;
- return array(
- 'success' => array(
- 'code' => 200,
- 'dolibarr_version' => DOL_VERSION,
- 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)?'0':$conf->global->MAIN_ONLY_LOGIN_ALLOWED)
- )
- );
+ return array(
+ 'success' => array(
+ 'code' => 200,
+ 'dolibarr_version' => DOL_VERSION,
+ 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)?'0':$conf->global->MAIN_ONLY_LOGIN_ALLOWED),
+ ),
+ );
}
}
diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php
index 1cdf78df4bf..109b0f1e94f 100644
--- a/htdocs/asset/admin/assets_extrafields.php
+++ b/htdocs/asset/admin/assets_extrafields.php
@@ -109,6 +109,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php
index d828bffa4de..e8f1d71370b 100644
--- a/htdocs/asset/admin/assets_type_extrafields.php
+++ b/htdocs/asset/admin/assets_type_extrafields.php
@@ -107,6 +107,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php
index c240f350590..1168fd3ada3 100644
--- a/htdocs/asset/admin/setup.php
+++ b/htdocs/asset/admin/setup.php
@@ -107,9 +107,8 @@ else
print '';
}
-
-// Page end
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php
index a34169ea0ac..9af7638316f 100644
--- a/htdocs/asset/card.php
+++ b/htdocs/asset/card.php
@@ -17,7 +17,7 @@
*/
/**
- * \file card.php
+ * \file htdocs/asset/card.php
* \ingroup asset
* \brief Page to create/edit/view asset
*/
@@ -25,8 +25,8 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
-include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
-include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
$langs->loadLangs(array("asset"));
@@ -95,8 +95,8 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
- $trigger_name='MYOBJECT_SENTBYMAIL';
- $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
+ $trigger_name='ASSET_SENTBYMAIL';
+ $autocopy='MAIN_MAIL_AUTOCOPY_ASSET_TO';
$trackid='asset'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
@@ -218,22 +218,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'xxx')
{
$formquestion=array();
- /*
- $formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
- }*/
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
}
- if (! $formconfirm) {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index 4ab05ce675c..596b795999d 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -35,18 +35,22 @@ class Asset extends CommonObject
* @var string ID to identify managed object
*/
public $element = 'asset';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'asset';
+
/**
* @var int Does module support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 0;
+
/**
* @var int Does asset support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
+
/**
* @var string String with name of icon for asset. Must be the part after the 'object_' into object_asset.png
*/
@@ -91,13 +95,36 @@ class Asset extends CommonObject
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Active', '-1'=>'Cancel')),
);
+
+ /**
+ * @var int ID
+ */
public $rowid;
+
+ /**
+ * @var string Ref
+ */
public $ref;
+
public $entity;
- public $label;
+
+ /**
+ * @var string Asset label
+ */
+ public $label;
+
public $amount;
- public $fk_soc;
+
+ /**
+ * @var int Thirdparty ID
+ */
+ public $fk_soc;
+
+ /**
+ * @var string description
+ */
public $description;
+
public $note_public;
public $note_private;
public $date_creation;
@@ -329,6 +356,7 @@ class Asset extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return the status
*
@@ -338,40 +366,35 @@ class Asset extends CommonObject
*/
static function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs;
- if ($mode == 0)
- {
- $prefix='';
- if ($status == 1) return $langs->trans('Enabled');
- if ($status == 0) return $langs->trans('Disabled');
- }
- if ($mode == 1)
+ if ($mode == 0 || $mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
@@ -461,4 +484,4 @@ class Asset extends CommonObject
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php
index 51ea3a0c799..df2f4c1415e 100644
--- a/htdocs/asset/class/asset_type.class.php
+++ b/htdocs/asset/class/asset_type.class.php
@@ -29,21 +29,38 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class AssetType extends CommonObject
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element = 'asset_type';
+
+ /**
+ * @var string ID to identify managed object
+ */
public $element = 'asset_type';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'group';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
/** @var string Label */
public $label;
+
/** @var string Accountancy code asset */
public $accountancy_code_asset;
+
/** @var string Accountancy code depreciation asset */
public $accountancy_code_depreciation_asset;
+
/** @var string Accountancy code depreciation expense */
public $accountancy_code_depreciation_expense;
+
/** @var string Public note */
public $note;
+
/** @var array Array of asset */
public $asset=array();
@@ -274,6 +291,7 @@ class AssetType extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of asset's type
*
@@ -281,6 +299,7 @@ class AssetType extends CommonObject
*/
function liste_array()
{
+ // phpcs:enable
global $conf,$langs;
$assettypes = array();
@@ -429,5 +448,4 @@ class AssetType extends CommonObject
{
return '';
}
-
}
diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php
index 66baaae196c..784f65aa220 100644
--- a/htdocs/asset/document.php
+++ b/htdocs/asset/document.php
@@ -17,7 +17,7 @@
*/
/**
- * \file document.php
+ * \file htdocs/asset/document.php
* \ingroup asset
* \brief Tab for documents linked to Assets
*/
@@ -100,7 +100,7 @@ if ($object->id)
dol_fiche_head($head, 'document', $langs->trans("Asset"), -1, 'generic');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -148,6 +148,6 @@ else
accessforbidden('',0,0);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php
index 71460f31a2c..9cc9495c1b9 100644
--- a/htdocs/asset/info.php
+++ b/htdocs/asset/info.php
@@ -16,7 +16,7 @@
*/
/**
- * \file info.php
+ * \file htdocs/asset/info.php
* \ingroup asset
* \brief Page to show an asset information
*/
@@ -79,5 +79,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index bcc2329f870..7e59ad4647f 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -18,7 +18,7 @@
*/
/**
- * \file list.php
+ * \file htdocs/asset/list.php
* \ingroup asset
* \brief List page for asset
*/
diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php
index cf0166df96f..e95e62aeaa4 100644
--- a/htdocs/asset/note.php
+++ b/htdocs/asset/note.php
@@ -17,7 +17,7 @@
*/
/**
- * \file note.php
+ * \file htdocs/asset/note.php
* \ingroup asset
* \brief Card with notes on Asset
*/
@@ -144,6 +144,6 @@ if ($id > 0 || ! empty($ref))
dol_fiche_end();
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index f4409ee5417..001912f7de3 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -851,7 +851,6 @@ if ($rowid > 0)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php
index e6b4985f6b8..56e90c1a639 100644
--- a/htdocs/asterisk/cidlookup.php
+++ b/htdocs/asterisk/cidlookup.php
@@ -31,9 +31,9 @@ include '../master.inc.php';
$phone = GETPOST('phone');
$notfound = $langs->trans("Unknown");
-
+
// Security check
-if (empty($conf->clicktodial->enabled))
+if (empty($conf->clicktodial->enabled))
{
print "Error: Module Click to dial is not enabled.\n";
exit;
diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php
index 8cd5ff979a0..66ff541d499 100644
--- a/htdocs/asterisk/wrapper.php
+++ b/htdocs/asterisk/wrapper.php
@@ -190,5 +190,6 @@ else {
print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php
index 26386052480..7086af7f17e 100644
--- a/htdocs/barcode/codeinit.php
+++ b/htdocs/barcode/codeinit.php
@@ -319,6 +319,6 @@ if ($conf->product->enabled || $conf->product->service)
print '';
print ' ';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index 7dfec76b39e..a1f3632fd2f 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -178,19 +178,19 @@ if ($action == 'builddoc')
{
// List of values to scan for a replacement
$substitutionarray = array (
- '%LOGIN%'=>$user->login,
- '%COMPANY%'=>$mysoc->name,
- '%ADDRESS%'=>$mysoc->address,
- '%ZIP%'=>$mysoc->zip,
- '%TOWN%'=>$mysoc->town,
- '%COUNTRY%'=>$mysoc->country,
- '%COUNTRY_CODE%'=>$mysoc->country_code,
- '%EMAIL%'=>$mysoc->email,
- '%YEAR%'=>$year,
- '%MONTH%'=>$month,
- '%DAY%'=>$day,
- '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
- '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
+ '%LOGIN%' => $user->login,
+ '%COMPANY%' => $mysoc->name,
+ '%ADDRESS%' => $mysoc->address,
+ '%ZIP%' => $mysoc->zip,
+ '%TOWN%' => $mysoc->town,
+ '%COUNTRY%' => $mysoc->country,
+ '%COUNTRY_CODE%' => $mysoc->country_code,
+ '%EMAIL%' => $mysoc->email,
+ '%YEAR%' => $year,
+ '%MONTH%' => $month,
+ '%DAY%' => $day,
+ '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT,
+ '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/",
);
complete_substitutions_array($substitutionarray, $langs);
@@ -416,7 +416,7 @@ print $langs->trans("BarcodeType").' ';
print '';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
$formbarcode = new FormBarCode($db);
-$formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1);
+print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1);
print '
';
// Barcode value
@@ -441,6 +441,6 @@ print ' ';
print ' ';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php
index 326fea79c5d..8c2835d856c 100644
--- a/htdocs/blockedlog/admin/blockedlog.php
+++ b/htdocs/blockedlog/admin/blockedlog.php
@@ -178,5 +178,6 @@ if (GETPOST('withtab','alpha'))
print ' ';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index dbb0affdbdf..cd558c020a6 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2017-2018 Laurent Destailleur
+/* Copyright (C) 2017 ATM Consulting
+ * Copyright (C) 2017-2018 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -117,10 +118,10 @@ else if (GETPOST('downloadcsv','alpha'))
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
$sql.= " WHERE entity = ".$conf->entity;
- if (GETPOST('yeartoexport','int') > 0)
+ if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
{
- $dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1);
- $datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12);
+ $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
+ $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
$sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
}
$sql.= " ORDER BY rowid ASC"; // Required so we get the first one
@@ -131,27 +132,34 @@ else if (GETPOST('downloadcsv','alpha'))
{
// Make the first fetch to get first line
$obj = $db->fetch_object($res);
-
- $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
- $firstid = $obj->rowid;
+ if ($obj)
+ {
+ $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
+ $firstid = $obj->rowid;
+ }
+ else
+ { // If not data found for filter, we do not need previoushash neither firstid
+ $previoushash = 'nodata';
+ $firstid = '';
+ }
}
else
{
$error++;
- setEventMessage($db->lasterror, 'errors');
+ setEventMessages($db->lasterror, null, 'errors');
}
}
if (! $error)
{
- // Now restart request with all data
+ // Now restart request with all data = no limit(1) in sql request
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
$sql.= " WHERE entity = ".$conf->entity;
- if (GETPOST('yeartoexport','int') > 0)
+ if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
{
- $dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1);
- $datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12);
+ $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
+ $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
$sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
}
$sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
@@ -161,7 +169,7 @@ else if (GETPOST('downloadcsv','alpha'))
{
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
- header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0?GETPOST('yeartoexport','int').'-':'').$previoushash. ".csv\"");
+ header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0 ? GETPOST('yeartoexport','int').(GETPOST('monthtoexport','int')>0?sprintf("%02d",GETPOST('monthtoexport','int')):'').'-':'').$previoushash. ".csv\"");
print $langs->transnoentities('Id')
.';'.$langs->transnoentities('Date')
@@ -243,7 +251,7 @@ else if (GETPOST('downloadcsv','alpha'))
}
else
{
- setEventMessage($db->lasterror, 'errors');
+ setEventMessages($db->lasterror, null, 'errors');
}
}
}
@@ -321,7 +329,20 @@ print '';
print $langs->trans("RestrictYearToExport").': ';
-print ' ';
+$smonth=GETPOST('monthtoexport','int');
+// Month
+$retstring='';
+$retstring.='';
+$retstring.=' ';
+for ($month = 1 ; $month <= 12 ; $month++)
+{
+ $retstring.='';
+ $retstring.=dol_print_date(mktime(12,0,0,$month,1,2000),"%b");
+ $retstring.=" ";
+}
+$retstring.=" ";
+print $retstring;
+print ' ';
print ' ';
print ' ';
if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').' ';
@@ -352,15 +373,15 @@ print ' ';
print '';
//print $langs->trans("from").': ';
-$form->select_date($search_start,'search_start');
+print $form->selectDate($search_start,'search_start');
//print ' ';
//print $langs->trans("to").': ';
-$form->select_date($search_end,'search_end');
+print $form->selectDate($search_end,'search_end');
print ' ';
// User
print '';
-print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
print ' ';
@@ -373,6 +394,7 @@ print ' ';
// Ref
print ' ';
+// Link to ref
print ' ';
// Amount
@@ -463,7 +485,6 @@ if (is_array($blocks))
// User
print '';
-
//print $block->getUser()
print $block->user_fullname;
print ' ';
@@ -475,7 +496,7 @@ if (is_array($blocks))
print ''.$block->ref_object.' ';
// Link to source object
- print ''.$object_link.' ';
+ print ''.$object_link.' ';
// Amount
print ''.price($block->amounts).' ';
@@ -484,8 +505,8 @@ if (is_array($blocks))
print ''.img_info($langs->trans('ShowDetails')).' ';
// Fingerprint
- print '';
- print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint');
+ print ' ';
+ print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
print ' ';
// Status
@@ -587,5 +608,6 @@ if (GETPOST('withtab','alpha'))
print ' ';
+// End of page
llxFooter();
-$db->close();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php
index b1084b01a54..b976857a522 100644
--- a/htdocs/blockedlog/class/authority.class.php
+++ b/htdocs/blockedlog/class/authority.class.php
@@ -50,10 +50,10 @@ class BlockedLogAuthority
*
* @param DoliDB $db Database handler
*/
- public function __construct($db) {
+ public function __construct($db)
+ {
$this->db = $db;
-
}
/**
@@ -61,7 +61,8 @@ class BlockedLogAuthority
*
* @return string blockchain
*/
- public function getLocalBlockChain() {
+ public function getLocalBlockChain()
+ {
$block_static = new BlockedLog($this->db);
@@ -84,10 +85,10 @@ class BlockedLogAuthority
*
* @return string hash md5 of blockchain
*/
- public function getBlockchainHash() {
+ public function getBlockchainHash()
+ {
return md5($this->signature.$this->blockchain);
-
}
/**
@@ -96,21 +97,22 @@ class BlockedLogAuthority
* @param string $hash hash md5 of blockchain to test
* @return boolean
*/
- public function checkBlockchain($hash) {
+ public function checkBlockchain($hash)
+ {
return ($hash === $this->getBlockchainHash() );
-
}
/**
* Add a new block to the chain
*
- * @param string $block new block to chain
+ * @param string $block new block to chain
+ * @return void
*/
- public function addBlock($block) {
+ public function addBlock($block)
+ {
$this->blockchain.=$block;
-
}
/**
@@ -119,7 +121,8 @@ class BlockedLogAuthority
* @param string $block new block to chain
* @return boolean
*/
- public function checkBlock($block) {
+ public function checkBlock($block)
+ {
if(strlen($block)!=64) return false;
@@ -141,7 +144,8 @@ class BlockedLogAuthority
* @param string $signature Signature of object to load
* @return int >0 if OK, <0 if KO, 0 if not found
*/
- public function fetch($id, $signature='') {
+ public function fetch($id, $signature='')
+ {
global $langs;
@@ -189,7 +193,6 @@ class BlockedLogAuthority
$this->error=$this->db->error();
return -1;
}
-
}
/**
@@ -198,7 +201,8 @@ class BlockedLogAuthority
* @param User $user Object user that create
* @return int <0 if KO, >0 if OK
*/
- public function create($user) {
+ public function create($user)
+ {
global $conf,$langs,$hookmanager;
@@ -243,7 +247,6 @@ class BlockedLogAuthority
$this->db->rollback();
return -1;
}
-
}
/**
@@ -252,7 +255,8 @@ class BlockedLogAuthority
* @param User $user Object user that create
* @return int <0 if KO, >0 if OK
*/
- public function update($user) {
+ public function update($user)
+ {
global $conf,$langs,$hookmanager;
@@ -281,7 +285,6 @@ class BlockedLogAuthority
$this->db->rollback();
return -1;
}
-
}
/**
@@ -289,7 +292,8 @@ class BlockedLogAuthority
*
* @return int <0 if KO, >0 if OK
*/
- public function syncSignatureWithAuthority() {
+ public function syncSignatureWithAuthority()
+ {
global $conf, $langs;
//TODO create cron task on activation
@@ -329,5 +333,4 @@ class BlockedLogAuthority
return 1;
}
-
-}
\ No newline at end of file
+}
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index 0210491fba7..dab99d80bc9 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -18,9 +18,6 @@
* See https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54
*/
-
-
-
/*ini_set('unserialize_callback_func', 'mycallback');
function mycallback($classname)
@@ -42,6 +39,7 @@ class BlockedLog
* @var int
*/
public $id;
+
/**
* Entity
* @var int
@@ -49,6 +47,10 @@ class BlockedLog
public $entity;
public $error = '';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
public $errors = array();
/**
@@ -171,6 +173,7 @@ class BlockedLog
/**
* Try to retrieve source object (it it still exists)
+ * @return string
*/
public function getObjectLink()
{
@@ -281,11 +284,11 @@ class BlockedLog
}
return ''.$langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object).' ';
-
}
/**
* try to retrieve user author
+ * @return string
*/
public function getUser()
{
@@ -609,7 +612,8 @@ class BlockedLog
* @param int $id Id of object to load
* @return int >0 if OK, <0 if KO, 0 if not found
*/
- public function fetch($id) {
+ public function fetch($id)
+ {
global $langs;
@@ -672,7 +676,6 @@ class BlockedLog
$this->error=$this->db->error();
return -1;
}
-
}
@@ -705,14 +708,13 @@ class BlockedLog
*
* @return boolean
*/
- public function setCertified() {
+ public function setCertified()
+ {
$res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id);
if($res===false) return false;
return true;
-
-
}
/**
@@ -722,7 +724,8 @@ class BlockedLog
* @param int $forcesignature Force signature (for example '0000000000' when we disabled the module)
* @return int <0 if KO, >0 if OK
*/
- public function create($user, $forcesignature='') {
+ public function create($user, $forcesignature='')
+ {
global $conf,$langs,$hookmanager;
@@ -1029,6 +1032,7 @@ class BlockedLog
* Check if module was already used or not for at least one recording.
*
* @param int $ignoresystem Ignore system events for the test
+ * @return bool
*/
function alreadyUsed($ignoresystem=0)
{
@@ -1053,6 +1057,4 @@ class BlockedLog
return $result;
}
-
}
-
diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php
index 25fa032902f..ed20f619b25 100644
--- a/htdocs/bookmarks/admin/bookmark.php
+++ b/htdocs/bookmarks/admin/bookmark.php
@@ -81,5 +81,6 @@ print ' ';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php
index d450e476506..b82c2b11b6c 100644
--- a/htdocs/bookmarks/card.php
+++ b/htdocs/bookmarks/card.php
@@ -336,7 +336,6 @@ if ($id > 0 && ! preg_match('/^add/i',$action))
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php
index 1beb4b36871..b7846cd0864 100644
--- a/htdocs/bookmarks/class/bookmark.class.php
+++ b/htdocs/bookmarks/class/bookmark.class.php
@@ -28,21 +28,44 @@
*/
class Bookmark extends CommonObject
{
- public $element='bookmark';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='bookmark';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='bookmark';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- public $picto = 'bookmark';
- var $db;
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'bookmark';
- var $id;
- var $fk_user;
- var $datec;
- var $url;
- var $target; // 0=replace, 1=new window
- var $title;
- var $position;
- var $favicon;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var int User ID
+ */
+ public $fk_user;
+
+ public $datec;
+ public $url;
+ public $target; // 0=replace, 1=new window
+ public $title;
+ public $position;
+ public $favicon;
/**
@@ -211,7 +234,6 @@ class Bookmark extends CommonObject
$this->error=$this->db->lasterror();
return -1;
}
-
}
/**
@@ -241,5 +263,4 @@ class Bookmark extends CommonObject
{
return '';
}
-
}
diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php
index ac5a89c66f3..10ce877c7e0 100644
--- a/htdocs/bookmarks/list.php
+++ b/htdocs/bookmarks/list.php
@@ -209,7 +209,7 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php
index f4af16b3739..62867d855cb 100644
--- a/htdocs/cashdesk/admin/cashdesk.php
+++ b/htdocs/cashdesk/admin/cashdesk.php
@@ -185,5 +185,6 @@ print ' \n";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php
index bd778f3422e..2a3c0279df8 100644
--- a/htdocs/cashdesk/affContenu.php
+++ b/htdocs/cashdesk/affContenu.php
@@ -87,7 +87,7 @@ print '
';
print '';
print '
';
-require ('tpl/liste_articles.tpl.php');
+require 'tpl/liste_articles.tpl.php';
print '
';
print '
';
diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php
index a2e467a35e3..9ff676531f1 100644
--- a/htdocs/cashdesk/affIndex.php
+++ b/htdocs/cashdesk/affIndex.php
@@ -36,9 +36,8 @@ if ( $_SESSION['uid'] <= 0 )
exit;
}
-$langs->load("companies");
-$langs->load("compta");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","compta","cashdesk"));
/*
diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php
index 5e431514d1c..78b76e20d11 100644
--- a/htdocs/cashdesk/class/Auth.class.php
+++ b/htdocs/cashdesk/class/Auth.class.php
@@ -138,6 +138,5 @@ class Auth
return $ret;
}
-
}
diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php
index a0e992e9da9..3051035813a 100644
--- a/htdocs/cashdesk/class/Facturation.class.php
+++ b/htdocs/cashdesk/class/Facturation.class.php
@@ -37,7 +37,12 @@ class Facturation
* int $prix => Prix HT du produit en cours
* int $tva => 'rowid' du taux de tva dans llx_c_tva
*/
- public $id;
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
protected $ref;
protected $qte;
protected $stock;
@@ -167,7 +172,6 @@ class Facturation
$_SESSION['poscart']=$newcartarray;
$this->raz();
-
}
/**
@@ -269,7 +273,6 @@ class Facturation
$this->prixTotalHt('RESET');
$this->montantTva('RESET');
$this->prixTotalTtc('RESET');
-
}
@@ -310,7 +313,7 @@ class Facturation
* @return string Ref
*/
public function ref($aRef=null)
- {
+ {
if (is_null($aRef))
{
@@ -324,7 +327,6 @@ class Facturation
{
$this->ref = $aRef;
}
-
}
/**
@@ -348,7 +350,6 @@ class Facturation
{
$this->qte = $aQte;
}
-
}
/**
@@ -372,7 +373,6 @@ class Facturation
{
$this->stock = $aStock;
}
-
}
/**
@@ -396,7 +396,6 @@ class Facturation
{
$this->remise_percent = $aRemisePercent;
}
-
}
/**
@@ -421,7 +420,6 @@ class Facturation
$this->montant_remise = $aMontantRemise;
}
-
}
/**
@@ -446,7 +444,6 @@ class Facturation
$this->prix = $aPrix;
}
-
}
/**
@@ -470,7 +467,6 @@ class Facturation
$this->tva = $aTva;
}
-
}
/**
@@ -518,7 +514,6 @@ class Facturation
$this->mode_reglement = $aModeReglement;
}
-
}
/**
@@ -543,7 +538,6 @@ class Facturation
$this->montant_encaisse = $aMontantEncaisse;
}
-
}
/**
@@ -567,7 +561,6 @@ class Facturation
$this->montant_rendu = $aMontantRendu;
}
-
}
/**
@@ -637,7 +630,6 @@ class Facturation
$this->montant_tva = $aMontantTva;
}
-
}
/**
@@ -652,7 +644,7 @@ class Facturation
{
return $this->prix_total_ttc;
}
- else if ( $aTotalTtc == 'RESET' )
+ elseif ( $aTotalTtc == 'RESET' )
{
$this->prix_total_ttc = null;
}
@@ -661,6 +653,4 @@ class Facturation
$this->prix_total_ttc = $aTotalTtc;
}
}
-
}
-
diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css
index d4149619aae..dc579711aa3 100644
--- a/htdocs/cashdesk/css/style.css
+++ b/htdocs/cashdesk/css/style.css
@@ -52,7 +52,7 @@ p {
}
.logopos {
padding-top: 20px;
- max-height: 40px;
+ max-height: 40px;
}
/* ------------------- Header ------------------- */
diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php
index f52890b68d2..6a2889f6e71 100644
--- a/htdocs/cashdesk/facturation.php
+++ b/htdocs/cashdesk/facturation.php
@@ -163,4 +163,4 @@ $obj_facturation->paiementLe('RESET');
// Affichage des templates
-require ('tpl/facturation1.tpl.php');
+require 'tpl/facturation1.tpl.php';
diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php
index 24b94562915..d2ea5160ca8 100644
--- a/htdocs/cashdesk/index.php
+++ b/htdocs/cashdesk/index.php
@@ -28,8 +28,8 @@
require_once '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
-$langs->load("admin");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("admin","cashdesk"));
// Test if user logged
if ( $_SESSION['uid'] > 0 )
@@ -63,7 +63,7 @@ top_htmlhead('','',0,0,'',$arrayofcss);
logo_small))
{
- print ' ';
+ print ' ';
}
else
{
diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php
index 238a73f6ef7..cd354293022 100644
--- a/htdocs/cashdesk/index_verif.php
+++ b/htdocs/cashdesk/index_verif.php
@@ -30,9 +30,8 @@ include '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Auth.class.php';
-$langs->load("main");
-$langs->load("admin");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("main","admin","cashdesk"));
$username = GETPOST("txtUsername");
$password = GETPOST("pwdPassword");
@@ -119,7 +118,7 @@ if ( $retour >= 0 )
$_SESSION['firstname'] = $tab['firstname'];
$_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : '');
$_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : '');
-
+
$_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : '');
$_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : '');
$_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : '');
@@ -135,8 +134,8 @@ if ( $retour >= 0 )
}
else
{
- $langs->load("errors");
- $langs->load("other");
+ // Load translation files required by the page
+ $langs->loadLangs(array("other","errors"));
$retour=$langs->trans("ErrorBadLoginPassword");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid);
exit;
diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php
index 146ae3d40b6..4ddafd17c44 100644
--- a/htdocs/cashdesk/tpl/facturation1.tpl.php
+++ b/htdocs/cashdesk/tpl/facturation1.tpl.php
@@ -3,6 +3,7 @@
* Copyright (C) 2011 Laurent Destailleur
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2015 Regis Houssin
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,10 +27,8 @@ if (empty($langs) || ! is_object($langs))
exit;
}
-
-$langs->load("main");
-$langs->load("bills");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("main","bills","cashdesk"));
// Object $form must de defined
@@ -204,7 +203,7 @@ $langs->load("cashdesk");
" onclick="javascript: verifClic('DIF');" />
trans("DateDue").' :';
- print $form->select_date(-1,'txtDatePaiement',0,0,0,'paymentmode',1,0,1);
+ print $form->selectDate(-1,'txtDatePaiement',0,0,0,'paymentmode',1,0);
print '';
?>
diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php
index 65f48b0603c..266c5e5840b 100644
--- a/htdocs/cashdesk/tpl/liste_articles.tpl.php
+++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php
@@ -28,9 +28,8 @@ if (empty($langs) || ! is_object($langs))
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-$langs->load("main");
-$langs->load("bills");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("main","bills","cashdesk"));
?>
diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php
index 250aaa18cc2..afe2c0da4ec 100644
--- a/htdocs/cashdesk/tpl/menu.tpl.php
+++ b/htdocs/cashdesk/tpl/menu.tpl.php
@@ -63,9 +63,8 @@ if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled)
$warehouseLink = $warehouse->getNomUrl(1);
}
-
-$langs->load("cashdesk");
-$langs->load("main");
+// Load translation files required by the page
+$langs->loadLangs(array("main","cashdesk"));
print "\n".''."\n";
print ' ';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php
index 3fd7d1c69b5..abea3f41eeb 100644
--- a/htdocs/categories/admin/categorie_extrafields.php
+++ b/htdocs/categories/admin/categorie_extrafields.php
@@ -79,7 +79,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -92,7 +92,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -111,6 +111,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php
index db56902347b..ce3324505eb 100644
--- a/htdocs/categories/card.php
+++ b/htdocs/categories/card.php
@@ -288,7 +288,6 @@ if ($user->rights->categorie->creer)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index c559d760f0f..843e2fc0ee6 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -103,7 +103,8 @@ class Categories extends DolibarrApi
*
* @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -266,7 +267,8 @@ class Categories extends DolibarrApi
* @param Categorie $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 70b2108dd4c..8f09710854f 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -6,7 +6,7 @@
* Copyright (C) 2006-2012 Laurent Destailleur
* Copyright (C) 2007 Patrick Raguin
* Copyright (C) 2013-2016 Juanjo Menent
- * Copyright (C) 2013-2016 Philippe Grand
+ * Copyright (C) 2013-2018 Philippe Grand
* Copyright (C) 2015 Marcos García
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2016 Charlie Benke
@@ -53,6 +53,9 @@ class Categorie extends CommonObject
const TYPE_ACCOUNT = 'bank_account';
const TYPE_BANK_LINE = 'bank_line';
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'category';
@@ -148,12 +151,28 @@ class Categorie extends CommonObject
'project' => 'projet',
);
+ /**
+ * @var string ID to identify managed object
+ */
public $element='category';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='categorie';
public $fk_parent;
- public $label;
+
+ /**
+ * @var string Category label
+ */
+ public $label;
+
+ /**
+ * @var string description
+ */
public $description;
+
/**
* @var string Color
*/
@@ -498,112 +517,27 @@ class Categorie extends CommonObject
$error++;
}
}
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_societe";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_fournisseur";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";
- $sql .= " WHERE fk_categ = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_lang";
- $sql .= " WHERE fk_category = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
- $error++;
- }
- }
-
- // Delete category
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie";
- $sql .= " WHERE rowid = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
+ $arraydelete = array(
+ 'categorie_societe' => 'fk_categorie',
+ 'categorie_fournisseur' => 'fk_categorie',
+ 'categorie_product' => 'fk_categorie',
+ 'categorie_member' => 'fk_categorie',
+ 'categorie_contact' => 'fk_categorie',
+ 'categorie_account' => 'fk_categorie',
+ 'bank_class' => 'fk_categ',
+ 'categorie_lang' => 'fk_category',
+ 'categorie' => 'rowid',
+ );
+ foreach ($arraydelete as $key => $value) {
+ $sql = "DELETE FROM " . MAIN_DB_PREFIX . $key;
+ $sql .= " WHERE ".$value." = ".$this->id;
+ if (!$this->db->query($sql)) {
+ $this->errors[] = $this->db->lasterror();
+ dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
+ $error++;
+ }
+ }
// Removed extrafields
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
@@ -628,6 +562,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Link an object to the category
*
@@ -637,6 +572,7 @@ class Categorie extends CommonObject
*/
function add_type($obj, $type)
{
+ // phpcs:enable
global $user,$langs,$conf;
$error=0;
@@ -729,6 +665,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete object from category
*
@@ -739,6 +676,7 @@ class Categorie extends CommonObject
*/
function del_type($obj,$type)
{
+ // phpcs:enable
global $user,$langs,$conf;
$error=0;
@@ -791,7 +729,7 @@ class Categorie extends CommonObject
*
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
* @param int $onlyids Return only ids of objects (consume less memory)
- * @return mixed -1 if KO, array of instance of object if OK
+ * @return array|int -1 if KO, array of instance of object if OK
* @see containsObject
*/
function getObjectsInCateg($type, $onlyids=0)
@@ -952,6 +890,7 @@ class Categorie extends CommonObject
return $categories;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return childs of a category
*
@@ -959,6 +898,7 @@ class Categorie extends CommonObject
*/
function get_filles()
{
+ // phpcs:enable
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE fk_parent = ".$this->id;
@@ -981,6 +921,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load this->motherof that is array(id_son=>id_parent, ...)
*
@@ -988,6 +929,7 @@ class Categorie extends CommonObject
*/
private function load_motherof()
{
+ // phpcs:enable
global $conf;
$this->motherof=array();
@@ -1015,6 +957,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Rebuilding the category tree as an array
* Return an array of table('id','id_mere',...) trie selon arbre et avec:
@@ -1032,6 +975,7 @@ class Categorie extends CommonObject
*/
function get_full_arbo($type, $markafterid=0)
{
+ // phpcs:enable
global $conf, $langs;
if (! is_numeric($type)) $type = $this->MAP_ID[$type];
@@ -1106,6 +1050,7 @@ class Categorie extends CommonObject
return $this->cats;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel
*
@@ -1115,6 +1060,7 @@ class Categorie extends CommonObject
*/
function build_path_from_id_categ($id_categ,$protection=1000)
{
+ // phpcs:enable
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
if (! empty($this->cats[$id_categ]['fullpath']))
@@ -1148,6 +1094,7 @@ class Categorie extends CommonObject
return;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Display content of $this->cats
*
@@ -1155,6 +1102,7 @@ class Categorie extends CommonObject
*/
function debug_cats()
{
+ // phpcs:enable
// Display $this->cats
foreach($this->cats as $key => $val)
{
@@ -1169,6 +1117,7 @@ class Categorie extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns all categories
*
@@ -1178,6 +1127,7 @@ class Categorie extends CommonObject
*/
function get_all_categories($type=null, $parent=false)
{
+ // phpcs:enable
if (! is_numeric($type)) $type = $this->MAP_ID[$type];
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
@@ -1206,6 +1156,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Check if no category with same label already exists for this cat's parent or root and for this cat's type
*
@@ -1213,6 +1164,7 @@ class Categorie extends CommonObject
*/
function already_exists()
{
+ // phpcs:enable
$type=$this->type;
if (! is_numeric($type)) $type=$this->MAP_ID[$type];
@@ -1255,6 +1207,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the top level categories (which are not girls)
*
@@ -1263,9 +1216,11 @@ class Categorie extends CommonObject
*/
function get_main_categories($type=null)
{
+ // phpcs:enable
return $this->get_all_categories($type, true);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the path of the category, with the names of the categories
* separated by $sep (" >> " by default)
@@ -1277,6 +1232,7 @@ class Categorie extends CommonObject
*/
function print_all_ways($sep = " >> ", $url='', $nocolor=0)
{
+ // phpcs:enable
$ways = array();
$allways = $this->get_all_ways(); // Load array of categories
@@ -1323,6 +1279,7 @@ class Categorie extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns an array containing the list of parent categories
*
@@ -1330,6 +1287,7 @@ class Categorie extends CommonObject
*/
function get_meres()
{
+ // phpcs:enable
$parents = array();
$sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie";
@@ -1357,6 +1315,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns in a table all possible paths to get to the category
* starting with the major categories represented by Tables of categories
@@ -1365,6 +1324,7 @@ class Categorie extends CommonObject
*/
function get_all_ways()
{
+ // phpcs:enable
$ways = array();
$parents=$this->get_meres();
@@ -1571,6 +1531,7 @@ class Categorie extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Deplace fichier uploade sous le nom $files dans le repertoire sdir
*
@@ -1580,6 +1541,7 @@ class Categorie extends CommonObject
*/
function add_photo($sdir, $file)
{
+ // phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/";
@@ -1620,6 +1582,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return tableau de toutes les photos de la categorie
*
@@ -1629,6 +1592,7 @@ class Categorie extends CommonObject
*/
function liste_photos($dir,$nbmax=0)
{
+ // phpcs:enable
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
$nbphoto=0;
@@ -1675,6 +1639,7 @@ class Categorie extends CommonObject
return $tabobj;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Efface la photo de la categorie et sa vignette
*
@@ -1683,6 +1648,7 @@ class Categorie extends CommonObject
*/
function delete_photo($file)
{
+ // phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
@@ -1703,6 +1669,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load size of image file
*
@@ -1711,6 +1678,7 @@ class Categorie extends CommonObject
*/
function get_image_size($file)
{
+ // phpcs:enable
$infoImg = getimagesize($file); // Recuperation des infos de l'image
$this->imgWidth = $infoImg[0]; // Largeur de l'image
$this->imgHeight = $infoImg[1]; // Hauteur de l'image
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index b420847f6fd..cdfac54fb9d 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -192,7 +192,6 @@ print ' ';
-
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index e57e51caf62..e634da4fe80 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -202,6 +202,6 @@ print "";
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index 472a8eb9b95..095c0c611c5 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -273,6 +273,6 @@ else
print $langs->trans("ErrorUnknown");
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index 7d71b43a81b..dbcfca198d2 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -334,5 +334,6 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print ' ';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 24e70e7d587..ba3580cea87 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -697,6 +697,6 @@ if ($type == Categorie::TYPE_PROJECT)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php
index 2c056cd0e07..e7b2ab51d7c 100644
--- a/htdocs/collab/index.php
+++ b/htdocs/collab/index.php
@@ -28,9 +28,8 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-$langs->load("admin");
-$langs->load("other");
-$langs->load("website");
+// Load translation files required by the page
+$langs->loadLangs(array("admin","other","website"));
if (! $user->admin) accessforbidden();
@@ -456,9 +455,6 @@ if ($action == 'editcontent')
print "\n\n";
-
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 1d6a0286b68..8fd1f1b0030 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2005 Simon TOSSER
* Copyright (C) 2005-2017 Regis Houssin
* Copyright (C) 2010-2013 Juanjo Menent
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014 Cedric GROSS
- * Copyright (C) 2015 Alexandre Spangaro
+ * Copyright (C) 2015 Alexandre Spangaro
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -689,9 +690,13 @@ if ($action == 'create')
$datep=($datep?$datep:$object->datep);
if (GETPOST('datep','int',1)) $datep=dol_stringtotime(GETPOST('datep','int',1),0);
print ''.$langs->trans("DateActionStart").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datep,'ap',1,1,0,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $form->select_date($datep,'ap',1,1,1,"action",1,1,0,0,'fulldayend');
- else $form->select_date($datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldayend');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } else {
+ print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+ }
print ' ';
// Date end
@@ -702,12 +707,17 @@ if ($action == 'create')
$datef=dol_time_plus_duree($datep, $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS, 'h');
}
print ''.$langs->trans("DateActionEnd").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } else {
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ }
print ' ';
- $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); // Dev in progress
+ // Dev in progress
+ $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
if ($userepeatevent)
{
// Repeat
@@ -927,6 +937,15 @@ if ($action == 'create')
if ($id > 0)
{
$result1=$object->fetch($id);
+ if ($result1 <= 0)
+ {
+ $langs->load("errors");
+ print $langs->trans("ErrorRecordNotFound");
+
+ llxFooter();
+ exit;
+ }
+
$result2=$object->fetch_thirdparty();
$result2=$object->fetch_projet();
$result3=$object->fetch_contact();
@@ -957,7 +976,7 @@ if ($id > 0)
$object->note = GETPOST("note",'none');
}
- if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
+ if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
{
dol_print_error($db,$object->error);
exit;
@@ -1048,30 +1067,38 @@ if ($id > 0)
// Date start
print ''.$langs->trans("DateActionStart").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datep?$datep:$object->datep,'ap',1,1,0,"action",1,1,0,0,'fulldaystart');
- else if (GETPOST("afaire") == 2) $form->select_date($datep?$datep:$object->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
- else $form->select_date($datep?$datep:$object->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datep?$datep:$object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datep?$datep:$object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+ } else {
+ print $form->selectDate($datep?$datep:$object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+ }
print ' ';
// Date end
print ''.$langs->trans("DateActionEnd").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- //else $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend','ap');
- else $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datef?$datef:$object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datef?$datef:$object->datef,'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } else {
+ print $form->selectDate($datef?$datef:$object->datef,'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ }
print ' ';
- $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); // Dev in progress
+ // Dev in progress
+ $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
if ($userepeatevent)
{
// Repeat
print ''.$langs->trans("RepeatEvent").' ';
print ' ';
- $arrayrecurrulefreq=array(
- 'no'=>$langs->trans("No"),
- 'MONTHLY'=>$langs->trans("EveryMonth"),
- 'WEEKLY'=>$langs->trans("EveryWeek"),
- //'DAYLY'=>$langs->trans("EveryDay")
- );
+ $arrayrecurrulefreq = array(
+ 'no'=>$langs->trans("No"),
+ 'MONTHLY'=>$langs->trans("EveryMonth"),
+ 'WEEKLY'=>$langs->trans("EveryWeek"),
+ //'DAYLY'=>$langs->trans("EveryDay"),
+ );
$selectedrecurrulefreq='no';
$selectedrecurrulebymonthday='';
$selectedrecurrulebyday='';
@@ -1241,8 +1268,13 @@ if ($id > 0)
if (! empty($object->fk_element) && ! empty($object->elementtype))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- print ' '.$langs->trans("LinkedObject").' ';
- print ''.dolGetElementUrl($object->fk_element,$object->elementtype,1).' ';
+ print '';
+ print ''.$langs->trans("LinkedObject").' ';
+ print ''.dolGetElementUrl($object->fk_element,$object->elementtype,1);
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
}
// Description
@@ -1611,7 +1643,6 @@ if ($id > 0)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 0c7ad11cb3c..7b9caabb8a9 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011-2017 Juanjo Menent
* Copyright (C) 2015 Marcos García
+ * Copyright (C) 2018 Nicolas ZABOURI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,15 +34,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class ActionComm extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='action';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element = 'actioncomm';
+
public $table_rowid = 'id';
- public $picto='action';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'action';
+
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user, 2=Same than 1 but accept record if fksoc is empty
* @var integer
@@ -52,7 +67,7 @@ class ActionComm extends CommonObject
* Id of the event
* @var int
*/
- var $id;
+ public $id;
/**
* Id of the event. Use $id as possible
@@ -66,7 +81,10 @@ class ActionComm extends CommonObject
var $type_color; // Color into parent table llx_c_actioncomm (used only if option to use type is set)
var $code; // Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...)
- var $label;
+ /**
+ * @var string Agenda event label
+ */
+ public $label;
/**
* @var string
@@ -423,7 +441,6 @@ class ActionComm extends CommonObject
$this->error=$this->db->lasterror();
return -1;
}
-
}
/**
@@ -620,7 +637,7 @@ class ActionComm extends CommonObject
$this->contact->id = $obj->fk_contact; // deprecated
$this->fk_element = $obj->elementid;
- $this->elementid = $obj->elementid;
+ $this->elementid = $obj->elementid;
$this->elementtype = $obj->elementtype;
$this->fetchResources();
@@ -634,7 +651,6 @@ class ActionComm extends CommonObject
}
return $num;
-
}
/**
@@ -682,6 +698,7 @@ class ActionComm extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Initialize this->userassigned array with list of id of user assigned to event
*
@@ -689,6 +706,7 @@ class ActionComm extends CommonObject
*/
function fetch_userassigned()
{
+ // phpcs:enable
$sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
$sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources";
$sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id;
@@ -883,7 +901,7 @@ class ActionComm extends CommonObject
$val=array('id'=>$val);
}
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
- $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['manadatory'])?'0':$val['manadatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")";
+ $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")";
$resql = $this->db->query($sql);
if (! $resql)
@@ -1004,6 +1022,7 @@ class ActionComm extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -1013,7 +1032,8 @@ class ActionComm extends CommonObject
*/
function load_board($user, $load_state_board=0)
{
- global $conf, $langs;
+ // phpcs:enable
+ global $conf, $langs;
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
else {
@@ -1128,6 +1148,7 @@ class ActionComm extends CommonObject
return $this->LibStatut($this->percentage,$mode,$hidenastatus,$this->datep);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of action status
*
@@ -1139,6 +1160,7 @@ class ActionComm extends CommonObject
*/
function LibStatut($percent,$mode,$hidenastatus=0,$datestart='')
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
@@ -1220,7 +1242,10 @@ class ActionComm extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
- $label = $this->label;
+ if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id))
+ $option = 'nolink';
+
+ $label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility
$result='';
@@ -1286,6 +1311,10 @@ class ActionComm extends CommonObject
$linkstart.=$linkclose.'>';
$linkend='';
+ if ($option == 'nolink') {
+ $linkstart = '';
+ $linkend = '';
+ }
//print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto;
if ($withpicto == 2)
@@ -1329,6 +1358,7 @@ class ActionComm extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Export events from database into a cal file.
*
@@ -1341,11 +1371,12 @@ class ActionComm extends CommonObject
*/
function build_exportfile($format,$type,$cachedelay,$filename,$filters)
{
+ // phpcs:enable
global $conf,$langs,$dolibarr_main_url_root,$mysoc;
- require_once (DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php");
- require_once (DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php");
- require_once (DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php");
+ require_once DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php";
+ require_once DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php";
+ require_once DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php";
dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
@@ -1659,8 +1690,6 @@ class ActionComm extends CommonObject
// TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done
-
-
// Delete also very old past events (we do not keep more than 1 month record in past)
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'";
$this->db->query($sql);
@@ -1669,6 +1698,4 @@ class ActionComm extends CommonObject
return $error;
}
-
}
-
diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php
index 4873db461f6..63773661cbd 100644
--- a/htdocs/comm/action/class/actioncommreminder.class.php
+++ b/htdocs/comm/action/class/actioncommreminder.class.php
@@ -34,14 +34,17 @@ class ActionCommReminder extends CommonObject
* @var string ID to identify managed object
*/
public $element = 'actioncomm_reminder';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'actioncomm_reminder';
+
/**
* @var array Does actioncommreminder support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 0;
+
/**
* @var string String with name of icon for actioncommreminder. Must be the part after the 'object_' into object_actioncommreminder.png
*/
@@ -81,7 +84,12 @@ class ActionCommReminder extends CommonObject
public $rowid;
public $dateremind;
public $typeremind;
+
+ /**
+ * @var int User ID
+ */
public $fk_user;
+
public $offsetvalue;
public $offsetunit;
public $status;
@@ -165,6 +173,7 @@ class ActionCommReminder extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return the status
*
@@ -174,40 +183,35 @@ class ActionCommReminder extends CommonObject
*/
static function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs;
- if ($mode == 0)
- {
- $prefix='';
- if ($status == 1) return $langs->trans('Done');
- if ($status == 0) return $langs->trans('ToDo');
- }
- if ($mode == 1)
+ if ($mode == 0 || $mode == 1)
{
if ($status == 1) return $langs->trans('Done');
if ($status == 0) return $langs->trans('ToDo');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done');
if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Done'),'statut4');
if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done');
if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4');
if ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4');
if ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5');
@@ -224,6 +228,4 @@ class ActionCommReminder extends CommonObject
{
$this->initAsSpecimenCommon();
}
-
}
-
diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php
index f5d9c7db762..677e477cd89 100644
--- a/htdocs/comm/action/class/api_agendaevents.class.php
+++ b/htdocs/comm/action/class/api_agendaevents.class.php
@@ -46,8 +46,8 @@ class AgendaEvents extends DolibarrApi
*/
function __construct()
{
- global $db, $conf;
- $this->db = $db;
+ global $db, $conf;
+ $this->db = $db;
$this->actioncomm = new ActionComm($this->db);
}
@@ -99,13 +99,14 @@ class AgendaEvents extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')"
* @return array Array of Agenda Events objects
*/
- function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') {
+ function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) {
- throw new RestException(401, "Insuffisant rights to read events");
+ throw new RestException(401, "Insuffisant rights to read events");
}
// case of external user
@@ -218,7 +219,7 @@ class AgendaEvents extends DolibarrApi
/**
- * Update Agenda Event general fields (won't touch lines of expensereport)
+ * Update Agenda Event general fields
*
* @param int $id Id of Agenda Event to update
* @param array $request_data Datas
@@ -226,7 +227,8 @@ class AgendaEvents extends DolibarrApi
* @return int
*/
/*
- function put($id, $request_data = null) {
+ function put($id, $request_data = null)
+ {
if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
throw new RestException(401, "Insuffisant rights to create your Agenda Event");
}
@@ -234,20 +236,20 @@ class AgendaEvents extends DolibarrApi
throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
- $result = $this->expensereport->fetch($id);
+ $result = $this->actioncomm->fetch($id);
if ( ! $result ) {
- throw new RestException(404, 'expensereport not found');
+ throw new RestException(404, 'actioncomm not found');
}
- if ( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
+ if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
- $this->expensereport->$field = $value;
+ $this->actioncomm->$field = $value;
}
- if ($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update'))
+ if ($this->actioncomm->update($id, DolibarrApiAccess::$user,1,'','','update'))
return $this->get($id);
return false;
@@ -291,7 +293,6 @@ class AgendaEvents extends DolibarrApi
'message' => 'Agenda Event deleted'
)
);
-
}
/**
@@ -319,7 +320,8 @@ class AgendaEvents extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index d8496a9a4ff..d6c25f6d4c1 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -24,24 +24,43 @@
/**
- * Class to manage different types of events
+ * Class to manage different types of events
*/
class CActionComm
{
- var $error;
- var $db;
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
- var $id;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- var $code;
- var $type;
- var $libelle; // deprecated
- var $label;
- var $active;
- var $color;
- var $picto;
+ /**
+ * @var int ID
+ */
+ public $id;
- var $type_actions=array();
+ public $code;
+ public $type;
+ public $libelle; // deprecated
+
+ /**
+ * @var string Type of agenda event label
+ */
+ public $label;
+
+ public $active;
+ public $color;
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto;
+
+ public $type_actions=array();
/**
@@ -99,6 +118,7 @@ class CActionComm
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of event types: array(id=>label) or array(code=>label)
*
@@ -112,6 +132,7 @@ class CActionComm
*/
function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0, $morefilter='', $shortlabel=0)
{
+ // phpcs:enable
global $langs,$conf;
$langs->load("commercial");
@@ -210,5 +231,4 @@ class CActionComm
$transcode=$langs->trans("Action".$this->code);
if ($transcode != "Action".$this->code) return $transcode;
}
-
}
diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php
index 708b52c9151..d3c2070d321 100644
--- a/htdocs/comm/action/class/ical.class.php
+++ b/htdocs/comm/action/class/ical.class.php
@@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php';
/**
- * Class to read/parse ICal calendars
+ * Class to read/parse ICal calendars
*/
class ICal
{
@@ -39,15 +39,15 @@ class ICal
var $last_key; //Help variable save last key (multiline string)
- /**
- * Constructor
- */
- public function __construct()
- {
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ }
- }
-
- /**
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
* Read text file, icalender text file
*
* @param string $file File
@@ -55,6 +55,7 @@ class ICal
*/
function read_file($file)
{
+ // phpcs:enable
$this->file = $file;
$file_text='';
@@ -67,6 +68,7 @@ class ICal
return $file_text; // return all text
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the number of calendar events
*
@@ -74,9 +76,11 @@ class ICal
*/
function get_event_count()
{
+ // phpcs:enable
return $this->event_count;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the number of to do
*
@@ -84,6 +88,7 @@ class ICal
*/
function get_todo_count()
{
+ // phpcs:enable
return $this->todo_count;
}
@@ -195,6 +200,7 @@ class ICal
return $this->cal;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add to $this->ical array one value and key.
*
@@ -205,6 +211,7 @@ class ICal
*/
function add_to_array($type, $key, $value)
{
+ // phpcs:enable
//print 'type='.$type.' key='.$key.' value='.$value.' '."\n";
@@ -255,6 +262,7 @@ class ICal
$this->last_key = $key;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value");
*
@@ -263,7 +271,8 @@ class ICal
*/
function retun_key_value($text)
{
- /*
+ // phpcs:enable
+ /*
preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches);
if (empty($matches))
@@ -275,9 +284,10 @@ class ICal
$matches = array_splice($matches, 1, 2);
return $matches;
}*/
- return explode(':',$text,2);
+ return explode(':',$text,2);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Parse RRULE return array
*
@@ -286,7 +296,8 @@ class ICal
*/
function ical_rrule($value)
{
- $result=array();
+ // phpcs:enable
+ $result = array();
$rrule = explode(';',$value);
foreach ($rrule as $line)
{
@@ -295,6 +306,8 @@ class ICal
}
return $result;
}
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS)
*
@@ -303,6 +316,7 @@ class ICal
*/
function ical_date_to_unix($ical_date)
{
+ // phpcs:enable
$ical_date = str_replace('T', '', $ical_date);
$ical_date = str_replace('Z', '', $ical_date);
@@ -316,6 +330,7 @@ class ICal
return $ntime; // ntime is a GTM time
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return unix date from iCal date format
*
@@ -325,7 +340,8 @@ class ICal
*/
function ical_dt_date($key, $value)
{
- $return_value=array();
+ // phpcs:enable
+ $return_value = array();
$value = $this->ical_date_to_unix($value);
// Analyse TZID
@@ -345,6 +361,7 @@ class ICal
return array($key,$return_value);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return sorted eventlist as array or false if calenar is empty
*
@@ -352,6 +369,7 @@ class ICal
*/
function get_sort_event_list()
{
+ // phpcs:enable
$temp = $this->get_event_list();
if (!empty($temp))
{
@@ -364,6 +382,7 @@ class ICal
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Compare two unix timestamp
*
@@ -373,9 +392,11 @@ class ICal
*/
function ical_dtstart_compare($a, $b)
{
+ // phpcs:enable
return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return eventlist array (not sort eventlist array)
*
@@ -383,9 +404,11 @@ class ICal
*/
function get_event_list()
{
+ // phpcs:enable
return (! empty($this->cal['VEVENT'])?$this->cal['VEVENT']:'');
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return eventlist array (not sort eventlist array)
*
@@ -393,9 +416,11 @@ class ICal
*/
function get_freebusy_list()
{
+ // phpcs:enable
return $this->cal['VFREEBUSY'];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return to do array (not sort to do array)
*
@@ -403,9 +428,11 @@ class ICal
*/
function get_todo_list()
{
+ // phpcs:enable
return $this->cal['VTODO'];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return base calendar data
*
@@ -413,9 +440,11 @@ class ICal
*/
function get_calender_data()
{
+ // phpcs:enable
return $this->cal['VCALENDAR'];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return array with all data
*
@@ -423,6 +452,7 @@ class ICal
*/
function get_all_data()
{
+ // phpcs:enable
return $this->cal;
}
}
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 43e5b89f115..a5998e220f7 100644
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -239,7 +239,7 @@ if ($object->id > 0)
print '';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -268,7 +268,6 @@ else
print $langs->trans("ErrorUnknown");
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 79b9d30d948..178e4bfb6d7 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -1250,8 +1250,8 @@ else // View by day
print "\n".'';
+// End of page
llxFooter();
-
$db->close();
@@ -1327,7 +1327,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
$colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
- $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ...
+ $nextindextouse=is_array($colorindexused)?count($colorindexused):0; // At first run this is 0, so fist user has 0, next 1, ...
//var_dump($colorindexused);
foreach ($eventarray as $daykey => $notused)
diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php
index 9a043a13690..2582e9b6b32 100644
--- a/htdocs/comm/action/info.php
+++ b/htdocs/comm/action/info.php
@@ -114,5 +114,6 @@ print '
';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 2c11a1de977..5628e65c6d9 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -4,6 +4,7 @@
* Copyright (C) 2004-2016 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2017 Open-DSI
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -189,9 +190,9 @@ $form=new Form($db);
$userstatic=new User($db);
$formactions=new FormActions($db);
-$nav='';
-$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
-$nav.=' ';
+$nav = '';
+$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
+$nav .=' ';
$now=dol_now();
@@ -438,15 +439,17 @@ if ($resql)
if (! empty($arrayfields['a.label']['checked'])) print ' ';
if (! empty($arrayfields['a.datep']['checked'])) {
print '';
- print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
+ print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0);
print ' ';
}
if (! empty($arrayfields['a.datep2']['checked'])) {
print '';
- print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1);
+ print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0);
print ' ';
}
- if (! empty($arrayfields['s.nom']['checked'])) print ' ';
+ if (! empty($arrayfields['s.nom']['checked'])) {
+ print ' ';
+ }
if (! empty($arrayfields['a.fk_contact']['checked'])) print ' ';
if (! empty($arrayfields['a.fk_element']['checked'])) print ' ';
@@ -672,7 +675,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php
index 2fdfa180319..31f22420cb8 100644
--- a/htdocs/comm/action/pertype.php
+++ b/htdocs/comm/action/pertype.php
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2014 Cedric GROSS
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -262,7 +263,7 @@ $nav.=' ';
$nav.=' ';
$nav.=' ';
-$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
+$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav.=' ';
$nav.='';
@@ -730,10 +731,8 @@ jQuery(document).ready(function() {
});
';
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 0cf056ef3a9..7b02857becf 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2014 Cedric GROSS
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -276,7 +277,7 @@ $nav.=' ';
$nav.=' ';
$nav.=' ';
*/
-$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
+$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav.=' ';
//$nav.='';
@@ -865,10 +866,8 @@ jQuery(document).ready(function() {
});
';
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php
index 7e4108b470b..ff1c7746afa 100644
--- a/htdocs/comm/action/rapport/index.php
+++ b/htdocs/comm/action/rapport/index.php
@@ -209,5 +209,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php
index 6a6aa12862a..becfabc949c 100644
--- a/htdocs/comm/admin/propal_extrafields.php
+++ b/htdocs/comm/admin/propal_extrafields.php
@@ -111,6 +111,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php
index 49784228fe6..7172c0e5b7c 100644
--- a/htdocs/comm/admin/propaldet_extrafields.php
+++ b/htdocs/comm/admin/propaldet_extrafields.php
@@ -86,7 +86,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 83db0e0f1d2..5874a7b855c 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -181,7 +181,7 @@ if (empty($reshook))
if ($action == 'setorder_min_amount')
{
$object->fetch($id);
- $object->order_min_amount=GETPOST('order_min_amount');
+ $object->order_min_amount=price2num(GETPOST('order_min_amount','alpha'));
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
@@ -423,15 +423,21 @@ if ($object->id > 0)
print '';
print ' ';
+ }
- print '';
- print '';
- print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
- print ' ';
- print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
-
- print ' ';
- print ' ';
+ if ($object->client)
+ {
+ if (! empty($conf->commande->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
+ {
+ print ''."\n";
+ print '';
+ print '';
+ print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
+ print ' ';
+ print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
+ print ' ';
+ print ' ';
+ }
}
@@ -582,7 +588,7 @@ if ($object->id > 0)
$link=DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id;
$icon='bill';
if ($link) $boxstat.='';
- $boxstat.='';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php
index 317c9902d52..7879612b099 100644
--- a/htdocs/comm/propal/info.php
+++ b/htdocs/comm/propal/info.php
@@ -127,5 +127,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 1a23c0b8728..dc6e4aff17b 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -78,13 +78,15 @@ $search_day=GETPOST("search_day","int");
$search_month=GETPOST("search_month","int");
$search_year=GETPOST("search_year","int");
$search_dayfin=GETPOST("search_dayfin","int");
-$search_monthfin=GETPOST("search_monthfin","int");
+$search_month_end=GETPOST("search_month_end","int");
$search_yearfin=GETPOST("search_yearfin","int");
$search_daydelivery=GETPOST("search_daydelivery","int");
$search_monthdelivery=GETPOST("search_monthdelivery","int");
$search_yeardelivery=GETPOST("search_yeardelivery","int");
$search_availability=GETPOST('search_availability','int');
$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
+$search_btn=GETPOST('button_search','alpha');
+$search_remove_btn=GETPOST('button_removefilter','alpha');
$viewstatut=GETPOST('viewstatut','alpha');
$optioncss = GETPOST('optioncss','alpha');
@@ -98,7 +100,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -159,6 +161,7 @@ $arrayfields=array(
'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
+ 'sale_representative'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>1),
'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
@@ -213,7 +216,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_month='';
$search_day='';
$search_yearfin='';
- $search_monthfin='';
+ $search_month_end='';
$search_dayfin='';
$search_yeardelivery='';
$search_monthdelivery='';
@@ -310,7 +313,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
-if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet);
+if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
@@ -343,14 +346,14 @@ else if ($search_year > 0)
{
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
}
-if ($search_monthfin > 0)
+if ($search_month_end > 0)
{
if ($search_yearfin > 0 && empty($search_dayfin))
- $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_monthfin,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_monthfin,false))."'";
+ $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_month_end,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_month_end,false))."'";
else if ($search_yearfin > 0 && ! empty($search_dayfin))
- $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthfin, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthfin, $search_dayfin, $search_yearfin))."'";
+ $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_end, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_end, $search_dayfin, $search_yearfin))."'";
else
- $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_monthfin)."'";
+ $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_month_end)."'";
}
else if ($search_yearfin > 0)
{
@@ -432,7 +435,7 @@ if ($resql)
if ($search_year) $param.='&search_year='.urlencode($search_year);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer);
- if ($search_refprojet) $param.='&search_refprojet='.urlencode($search_refprojet);
+ if ($search_refproject) $param.='&search_refproject='.urlencode($search_refproject);
if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
@@ -615,7 +618,7 @@ if ($resql)
print ' ';
//print $langs->trans('Month').': ';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
+ print ' ';
//print ' '.$langs->trans('Year').': ';
$formother->select_year($search_yearfin,'search_yearfin',1, 20, 5);
print ' ';
@@ -667,6 +670,10 @@ if ($resql)
print ' ';
print '';
}
+ if (! empty($arrayfields['sale_representative']['checked']))
+ {
+ print ' ';
+ }
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -721,6 +728,7 @@ if ($resql)
if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'],$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
@@ -943,6 +951,51 @@ if ($resql)
if (! $i) $totalarray['nbfield']++;
}
+ if (! empty($arrayfields['sale_representative']['checked']))
+ {
+ // Sales representatives
+ print '';
+ if ($obj->socid > 0)
+ {
+ $listsalesrepresentatives=$companystatic->getSalesRepresentatives($user);
+ if ($listsalesrepresentatives < 0) dol_print_error($db);
+ $nbofsalesrepresentative=count($listsalesrepresentatives);
+ if ($nbofsalesrepresentative > 3) // We print only number
+ {
+ print '';
+ print $nbofsalesrepresentative;
+ print ' ';
+ }
+ else if ($nbofsalesrepresentative > 0)
+ {
+ $userstatic=new User($db);
+ $j=0;
+ foreach($listsalesrepresentatives as $val)
+ {
+ $userstatic->id=$val['id'];
+ $userstatic->lastname=$val['lastname'];
+ $userstatic->firstname=$val['firstname'];
+ $userstatic->email=$val['email'];
+ $userstatic->statut=$val['statut'];
+ $userstatic->entity=$val['entity'];
+ $userstatic->photo=$val['photo'];
+
+ //print '':
+ print $userstatic->getNomUrl(-2);
+ $j++;
+ if ($j < $nbofsalesrepresentative) print ' ';
+ //print '
';
+ }
+ }
+ //else print $langs->trans("NoSalesRepresentativeAffected");
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' ';
+ }
+
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
@@ -988,27 +1041,40 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
+ if (isset($totalarray['totalhtfield'])
|| isset($totalarray['totalvatfield'])
|| isset($totalarray['totalttcfield'])
|| isset($totalarray['totalamfield'])
|| isset($totalarray['totalrtpfield'])
+ || isset($totalarray['totalizable'])
)
{
print '';
$i=0;
while ($i < $totalarray['nbfield'])
{
- $i++;
- if ($i == 1)
- {
+ $i++;
+ if ($i == 1)
+ {
if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
+ }
+ elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
+ elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
+ elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
+ elseif ($totalarray['totalizable']) {
+ $printed = false;
+ foreach ($totalarray['totalizable'] as $totalizable) {
+ if ($totalizable['pos']==$i && ! $printed) {
+ print ''.price($totalizable['total']).' ';
+ $printed = true;
+ }
+ }
+ if (! $printed) {
+ print ' ';
+ }
+ }
+ else print ' ';
}
print ' ';
}
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 607cff245d9..a346f8df18f 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -144,6 +144,6 @@ if ($id > 0 || ! empty($ref))
}
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php
index ac6b42c45d8..00db6264377 100644
--- a/htdocs/comm/propal/stats/index.php
+++ b/htdocs/comm/propal/stats/index.php
@@ -344,7 +344,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
index cd49ca863e6..724e0bcce15 100644
--- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
@@ -57,7 +57,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)
{
$url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id;
- print ' ';
+ print ' ';
}
?>
diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php
index 2273012696f..6d7e93af4be 100644
--- a/htdocs/comm/prospect/index.php
+++ b/htdocs/comm/prospect/index.php
@@ -275,6 +275,6 @@ if ($resql)
//print '';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php
index 50127d719c8..93cfada8860 100644
--- a/htdocs/comm/prospect/recap-prospect.php
+++ b/htdocs/comm/prospect/recap-prospect.php
@@ -89,5 +89,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php
index 6cd41c6c658..86c1bad0521 100644
--- a/htdocs/comm/recap-client.php
+++ b/htdocs/comm/recap-client.php
@@ -89,5 +89,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php
index 6f3287b8831..f045e570c6e 100644
--- a/htdocs/comm/remise.php
+++ b/htdocs/comm/remise.php
@@ -129,8 +129,9 @@ if ($socid > 0)
print '';
- llxFooter();
- $db->close();
+ // End of page
+ llxFooter();
+ $db->close();
exit;
}
@@ -324,5 +325,6 @@ if ($socid > 0)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index 3eec109e6b3..78e4643d5e3 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -998,5 +998,6 @@ if ($socid > 0)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index b0cea3318cb..0dd266ef186 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -5,13 +5,14 @@
* Copyright (C) 2005-2015 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2010-2013 Juanjo Menent
- * Copyright (C) 2011-2016 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2012-2016 Marcos García
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -679,7 +680,7 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++;
}
- if ($prod_entry_mode == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && (! ($price_ht_devise >= 0) || $price_ht_devise == '')) // Unit price can be 0 but not ''
+ if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for order.
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++;
@@ -700,8 +701,10 @@ if (empty($reshook))
if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
$idprod = $res->fk_product_child;
- } else {
- setEventMessage($langs->trans('ErrorProductCombinationNotFound'), 'errors');
+ }
+ else
+ {
+ setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors');
$error ++;
}
}
@@ -1577,7 +1580,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Date
print '' . $langs->trans('Date') . ' ';
- $form->select_date('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
+ print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
print ' ';
// Delivery date planed
@@ -1587,7 +1590,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY)?-1:'';
}
- $form->select_date($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1);
+ print $form->selectDate($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1);
print "";
// Conditions de reglement
@@ -1858,13 +1861,14 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value'
- // => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"),
- // 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse','int')?GETPOST('idwarehouse','int'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
@@ -1890,13 +1894,14 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value'
- // => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"),
- // 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220);
@@ -1931,13 +1936,14 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value'
- // => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"),
- // 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1);
@@ -1962,12 +1968,11 @@ if ($action == 'create' && $user->rights->commande->creer)
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneOrder'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
- if (! $formconfirm) {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
@@ -2082,7 +2087,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print 'id . '" method="post">';
print ' ';
print ' ';
- $form->select_date($object->date, 'order_', '', '', '', "setdate");
+ print $form->selectDate($object->date, 'order_', '', '', '', "setdate");
print ' ';
print ' ';
} else {
@@ -2107,7 +2112,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print 'id . '" method="post">';
print ' ';
print ' ';
- $form->select_date($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison");
+ print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison");
print ' ';
print ' ';
} else {
@@ -2384,7 +2389,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Total HT
$alert = '';
- if($object->total_ht < $object->thirdparty->order_min_amount) {
+ if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) {
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
}
print '' . $langs->trans('AmountHT') . ' ';
@@ -2673,5 +2678,6 @@ if ($action == 'create' && $user->rights->commande->creer)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index e52da47e11b..60011592afe 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -97,9 +97,10 @@ class Orders extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of order objects
*
- * @throws RestException
+ * @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -185,9 +186,9 @@ class Orders extends DolibarrApi
*/
function post($request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401, "Insuffisant rights");
- }
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401, "Insuffisant rights");
+ }
// Check mandatory fields
$result = $this->_validate($request_data);
@@ -218,25 +219,26 @@ class Orders extends DolibarrApi
*
* @return int
*/
- function getLines($id) {
- if(! DolibarrApiAccess::$user->rights->commande->lire) {
- throw new RestException(401);
- }
+ function getLines($id)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->lire) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $this->commande->getLinesArray();
- $result = array();
- foreach ($this->commande->lines as $line) {
- array_push($result,$this->_cleanObjectDatas($line));
- }
- return $result;
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $this->commande->getLinesArray();
+ $result = array();
+ foreach ($this->commande->lines as $line) {
+ array_push($result,$this->_cleanObjectDatas($line));
+ }
+ return $result;
}
/**
@@ -249,21 +251,22 @@ class Orders extends DolibarrApi
*
* @return int
*/
- function postLine($id, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function postLine($id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $request_data = (object) $request_data;
- $updateRes = $this->commande->addline(
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->commande->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
@@ -290,15 +293,14 @@ class Orders extends DolibarrApi
$request_data->origin,
$request_data->origin_id,
$request_data->multicurrency_subprice
- );
+ );
- if ($updateRes > 0) {
- return $updateRes;
+ if ($updateRes > 0) {
+ return $updateRes;
- }
- else {
+ } else {
throw new RestException(400, $this->commande->error);
- }
+ }
}
/**
@@ -312,51 +314,52 @@ class Orders extends DolibarrApi
*
* @return object
*/
- function putLine($id, $lineid, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function putLine($id, $lineid, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $request_data = (object) $request_data;
- $updateRes = $this->commande->updateline(
- $lineid,
- $request_data->desc,
- $request_data->subprice,
- $request_data->qty,
- $request_data->remise_percent,
- $request_data->tva_tx,
- $request_data->localtax1_tx,
- $request_data->localtax2_tx,
- 'HT',
- $request_data->info_bits,
- $request_data->date_start,
- $request_data->date_end,
- $request_data->product_type,
- $request_data->fk_parent_line,
- 0,
- $request_data->fk_fournprice,
- $request_data->pa_ht,
- $request_data->label,
- $request_data->special_code,
- $request_data->array_options,
- $request_data->fk_unit,
- $request_data->multicurrency_subprice
- );
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->commande->updateline(
+ $lineid,
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->remise_percent,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ 'HT',
+ $request_data->info_bits,
+ $request_data->date_start,
+ $request_data->date_end,
+ $request_data->product_type,
+ $request_data->fk_parent_line,
+ 0,
+ $request_data->fk_fournprice,
+ $request_data->pa_ht,
+ $request_data->label,
+ $request_data->special_code,
+ $request_data->array_options,
+ $request_data->fk_unit,
+ $request_data->multicurrency_subprice
+ );
- if ($updateRes > 0) {
- $result = $this->get($id);
- unset($result->line);
- return $this->_cleanObjectDatas($result);
- }
- return false;
+ if ($updateRes > 0) {
+ $result = $this->get($id);
+ unset($result->line);
+ return $this->_cleanObjectDatas($result);
+ }
+ return false;
}
/**
@@ -372,30 +375,29 @@ class Orders extends DolibarrApi
* @throws 401
* @throws 404
*/
- function deleteLine($id, $lineid) {
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function deleteLine($id, $lineid)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- // TODO Check the lineid $lineid is a line of ojbect
+ // TODO Check the lineid $lineid is a line of ojbect
- $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
- if ($updateRes > 0) {
- return $this->get($id);
- }
- else
- {
- throw new RestException(405, $this->commande->error);
- }
+ $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
+ if ($updateRes > 0) {
+ return $this->get($id);
+ } else {
+ throw new RestException(405, $this->commande->error);
+ }
}
/**
@@ -406,10 +408,11 @@ class Orders extends DolibarrApi
*
* @return int
*/
- function put($id, $request_data = null) {
- if (! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function put($id, $request_data = null)
+ {
+ if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
$result = $this->commande->fetch($id);
if (! $result) {
@@ -470,7 +473,6 @@ class Orders extends DolibarrApi
'message' => 'Order deleted'
)
);
-
}
/**
@@ -547,24 +549,25 @@ class Orders extends DolibarrApi
* @throws 404
* @throws 405
*/
- function reopen($id) {
+ function reopen($id)
+ {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Order ID is mandatory');
+ throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(405, $this->commande->error);
+ throw new RestException(405, $this->commande->error);
}else if( $result == 0) {
- throw new RestException(304);
+ throw new RestException(304);
}
return $result;
@@ -584,22 +587,23 @@ class Orders extends DolibarrApi
* @throws 404
* @throws 405
*/
- function setinvoiced($id) {
+ function setinvoiced($id)
+ {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Order ID is mandatory');
+ throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
$result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(400, $this->commande->error);
+ throw new RestException(400, $this->commande->error);
}
$result = $this->commande->fetch($id);
@@ -675,23 +679,23 @@ class Orders extends DolibarrApi
function settodraft($id, $idwarehouse=-1)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->commande->set_draft(DolibarrApiAccess::$user, $idwarehouse);
if ($result == 0) {
- throw new RestException(304, 'Nothing done. May be object is already closed');
+ throw new RestException(304, 'Nothing done. May be object is already closed');
}
if ($result < 0) {
- throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
+ throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
}
$result = $this->commande->fetch($id);
@@ -709,43 +713,44 @@ class Orders extends DolibarrApi
}
- /**
- * Create an order using an existing proposal.
- *
- *
- * @param int $proposalid Id of the proposal
- *
- * @url POST /createfromproposal/{proposalid}
- *
- * @return int
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
- */
- function createOrderFromProposal($proposalid) {
+ /**
+ * Create an order using an existing proposal.
+ *
+ *
+ * @param int $proposalid Id of the proposal
+ *
+ * @url POST /createfromproposal/{proposalid}
+ *
+ * @return int
+ * @throws 400
+ * @throws 401
+ * @throws 404
+ * @throws 405
+ */
+ function createOrderFromProposal($proposalid)
+ {
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
if(! DolibarrApiAccess::$user->rights->propal->lire) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($proposalid)) {
- throw new RestException(400, 'Proposal ID is mandatory');
+ throw new RestException(400, 'Proposal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($proposalid);
if( ! $result ) {
- throw new RestException(404, 'Proposal not found');
+ throw new RestException(404, 'Proposal not found');
}
$result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(405, $this->commande->error);
+ throw new RestException(405, $this->commande->error);
}
$this->commande->fetchObjectLinked();
@@ -759,7 +764,8 @@ class Orders extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
@@ -785,7 +791,7 @@ class Orders extends DolibarrApi
$commande = array();
foreach (Orders::$FIELDS as $field) {
if (!isset($data[$field]))
- throw new RestException(400, "$field field missing");
+ throw new RestException(400, $field ." field missing");
$commande[$field] = $data[$field];
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index a9970a95a51..65459d37895 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -42,108 +42,137 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php';
*/
class Commande extends CommonOrder
{
- public $element='commande';
- public $table_element='commande';
- public $table_element_line = 'commandedet';
- public $class_element_line = 'OrderLine';
- public $fk_element = 'fk_commande';
- public $picto = 'order';
- /**
- * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- * @var int
- */
- public $ismultientitymanaged = 1;
- /**
- * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
- * @var integer
- */
- public $restrictiononfksoc = 1;
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='commande';
- /**
- * {@inheritdoc}
- */
- protected $table_ref_field = 'ref';
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='commande';
+
+ /**
+ * @var int Name of subtable line
+ */
+ public $table_element_line = 'commandedet';
+
+ public $class_element_line = 'OrderLine';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
+ public $fk_element = 'fk_commande';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'order';
+
+ /**
+ * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+ * @var int
+ */
+ public $ismultientitymanaged = 1;
+
+ /**
+ * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
+ * @var integer
+ */
+ public $restrictiononfksoc = 1;
+
+ /**
+ * {@inheritdoc}
+ */
+ protected $table_ref_field = 'ref';
/**
* Client ID
* @var int
*/
- public $socid;
+ public $socid;
- public $ref_client;
- public $ref_int;
- public $contactid;
+ public $ref_client;
+ public $ref_int;
+ public $contactid;
/**
* Status of the order
* @var int
*/
- public $statut;
+ public $statut;
+
/**
* Billed
* @var int
*/
- public $billed; // billed or not
+ public $billed; // billed or not
- public $brouillon;
- public $cond_reglement_code;
+ public $brouillon;
+ public $cond_reglement_code;
- public $fk_account;
+ public $fk_account;
- /**
- * It holds the label of the payment mode. Use it in case translation cannot be found.
- * @var string
- */
- public $mode_reglement;
+ /**
+ * It holds the label of the payment mode. Use it in case translation cannot be found.
+ * @var string
+ */
+ public $mode_reglement;
- /**
- * Payment mode id
- * @var int
- */
- public $mode_reglement_id;
- /**
- * Payment mode code
- * @var string
- */
- public $mode_reglement_code;
- /**
- * Availability delivery time id
- * @var int
- */
- public $availability_id;
- /**
- * Availability delivery time code
- * @var string
- */
- public $availability_code;
- /**
- * Label of availability delivery time. Use it in case translation cannot be found.
- * @var string
- */
- public $availability;
+ /**
+ * Payment mode id
+ * @var int
+ */
+ public $mode_reglement_id;
+
+ /**
+ * Payment mode code
+ * @var string
+ */
+ public $mode_reglement_code;
+
+ /**
+ * Availability delivery time id
+ * @var int
+ */
+ public $availability_id;
+
+ /**
+ * Availability delivery time code
+ * @var string
+ */
+ public $availability_code;
+
+ /**
+ * Label of availability delivery time. Use it in case translation cannot be found.
+ * @var string
+ */
+ public $availability;
+
+ public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
+ public $demand_reason_code;
+ public $date; // Date commande
- public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
- public $demand_reason_code;
- public $date; // Date commande
/**
* @deprecated
* @see date
*/
- public $date_commande;
- public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
- public $fk_remise_except;
- public $remise_percent;
- public $remise_absolue;
- public $info_bits;
- public $rang;
- public $special_code;
- public $source; // Order mode. How we received order (by phone, by email, ...)
- public $extraparams=array();
+ public $date_commande;
- public $linked_objects=array();
+ public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
+ public $fk_remise_except;
+ public $remise_percent;
+ public $remise_absolue;
+ public $info_bits;
+ public $rang;
+ public $special_code;
+ public $source; // Order mode. How we received order (by phone, by email, ...)
+ public $extraparams=array();
- public $user_author_id;
- public $user_valid;
+ public $linked_objects=array();
+
+ public $user_author_id;
+ public $user_valid;
/**
* @var OrderLine[]
@@ -160,10 +189,10 @@ class Commande extends CommonOrder
public $oldcopy;
- /**
- * ERR Not enough stock
- */
- const STOCK_NOT_ENOUGH_FOR_ORDER = -3;
+ /**
+ * ERR Not enough stock
+ */
+ const STOCK_NOT_ENOUGH_FOR_ORDER = -3;
/**
* Canceled status
@@ -189,445 +218,449 @@ class Commande extends CommonOrder
const STATUS_CLOSED = 3;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- function __construct($db)
- {
- $this->db = $db;
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ function __construct($db)
+ {
+ $this->db = $db;
- $this->remise = 0;
- $this->remise_percent = 0;
+ $this->remise = 0;
+ $this->remise_percent = 0;
- $this->products = array();
- }
+ $this->products = array();
+ }
- /**
+ /**
* Returns the reference to the following non used Order depending on the active numbering module
* defined into COMMANDE_ADDON
*
* @param Societe $soc Object thirdparty
* @return string Order free reference
*/
- function getNextNumRef($soc)
- {
- global $langs, $conf;
- $langs->load("order");
+ function getNextNumRef($soc)
+ {
+ global $langs, $conf;
+ $langs->load("order");
- if (! empty($conf->global->COMMANDE_ADDON))
- {
- $mybool=false;
+ if (! empty($conf->global->COMMANDE_ADDON))
+ {
+ $mybool=false;
- $file = $conf->global->COMMANDE_ADDON.".php";
+ $file = $conf->global->COMMANDE_ADDON.".php";
$classname = $conf->global->COMMANDE_ADDON;
// Include file with class
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
- $dir = dol_buildpath($reldir."core/modules/commande/");
+ $dir = dol_buildpath($reldir."core/modules/commande/");
- // Load file with numbering class (if found)
- $mybool|=@include_once $dir.$file;
- }
+ // Load file with numbering class (if found)
+ $mybool|=@include_once $dir.$file;
+ }
- if (! $mybool)
- {
- dol_print_error('',"Failed to include file ".$file);
- return '';
- }
+ if (! $mybool)
+ {
+ dol_print_error('',"Failed to include file ".$file);
+ return '';
+ }
- $obj = new $classname();
- $numref = $obj->getNextValue($soc,$this);
+ $obj = new $classname();
+ $numref = $obj->getNextValue($soc,$this);
- if ($numref != "")
- {
- return $numref;
- }
- else
+ if ($numref != "")
+ {
+ return $numref;
+ }
+ else
{
$this->error=$obj->error;
- //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
- return "";
- }
- }
- else
- {
- print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_NotDefined");
- return "";
- }
- }
-
-
- /**
- * Validate order
- *
- * @param User $user User making status change
- * @param int $idwarehouse Id of warehouse to use for stock decrease
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <=0 if OK, 0=Nothing done, >0 if KO
- */
- function valid($user, $idwarehouse=0, $notrigger=0)
- {
- global $conf,$langs;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- $error=0;
-
- // Protection
- if ($this->statut == self::STATUS_VALIDATED)
- {
- dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING);
- return 0;
- }
-
- if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
- {
- $this->error='NotEnoughPermissions';
- dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
- return -1;
- }
-
- $now=dol_now();
-
- $this->db->begin();
-
- // Definition du nom de module de numerotation de commande
- $soc = new Societe($this->db);
- $soc->fetch($this->socid);
-
- // Class of company linked to order
- $result=$soc->set_as_client();
-
- // Define new ref
- if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
- {
- $num = $this->getNextNumRef($soc);
- }
- else
+ //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
+ return "";
+ }
+ }
+ else
{
- $num = $this->ref;
- }
- $this->newref = $num;
+ print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_NotDefined");
+ return "";
+ }
+ }
- // Validate
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET ref = '".$num."',";
- $sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
- $sql.= " date_valid='".$this->db->idate($now)."',";
- $sql.= " fk_user_valid = ".$user->id;
- $sql.= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::valid()", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (! $resql)
- {
- dol_print_error($this->db);
- $this->error=$this->db->lasterror();
- $error++;
- }
+ /**
+ * Validate order
+ *
+ * @param User $user User making status change
+ * @param int $idwarehouse Id of warehouse to use for stock decrease
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <=0 if OK, 0=Nothing done, >0 if KO
+ */
+ function valid($user, $idwarehouse=0, $notrigger=0)
+ {
+ global $conf,$langs;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- if (! $error)
- {
- // If stock is incremented on validate order, we must increment it
- if ($result >= 0 && ! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
- {
- require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
- $langs->load("agenda");
+ $error=0;
- // Loop on each line
- $cpt=count($this->lines);
- for ($i = 0; $i < $cpt; $i++)
- {
- if ($this->lines[$i]->fk_product > 0)
- {
- $mouvP = new MouvementStock($this->db);
+ // Protection
+ if ($this->statut == self::STATUS_VALIDATED)
+ {
+ dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING);
+ return 0;
+ }
+
+ if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
+ {
+ $this->error='NotEnoughPermissions';
+ dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ $now=dol_now();
+
+ $this->db->begin();
+
+ // Definition du nom de module de numerotation de commande
+ $soc = new Societe($this->db);
+ $soc->fetch($this->socid);
+
+ // Class of company linked to order
+ $result=$soc->set_as_client();
+
+ // Define new ref
+ if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
+ {
+ $num = $this->getNextNumRef($soc);
+ }
+ else
+ {
+ $num = $this->ref;
+ }
+ $this->newref = $num;
+
+ // Validate
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET ref = '".$num."',";
+ $sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
+ $sql.= " date_valid='".$this->db->idate($now)."',";
+ $sql.= " fk_user_valid = ".$user->id;
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(get_class($this)."::valid()", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ // If stock is incremented on validate order, we must increment it
+ if ($result >= 0 && ! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+ $langs->load("agenda");
+
+ // Loop on each line
+ $cpt=count($this->lines);
+ for ($i = 0; $i < $cpt; $i++)
+ {
+ if ($this->lines[$i]->fk_product > 0)
+ {
+ $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
- // We decrement stock of product (and sub-products)
- $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num));
- if ($result < 0)
- {
- $error++;
- $this->error=$mouvP->error;
- }
- }
- if ($error) break;
- }
- }
- }
+ // We decrement stock of product (and sub-products)
+ $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num));
+ if ($result < 0)
+ {
+ $error++;
+ $this->error=$mouvP->error;
+ }
+ }
+ if ($error) break;
+ }
+ }
+ }
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_VALIDATE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->oldref = $this->ref;
-
- // Rename directory if dir was a temporary ref
- if (preg_match('/^[\(]?PROV/i', $this->ref))
- {
- // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
- // in order not to lose the attachments
- $oldref = dol_sanitizeFileName($this->ref);
- $newref = dol_sanitizeFileName($num);
- $dirsource = $conf->commande->dir_output.'/'.$oldref;
- $dirdest = $conf->commande->dir_output.'/'.$newref;
- if (file_exists($dirsource))
- {
- dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
-
- if (@rename($dirsource, $dirdest))
- {
- dol_syslog("Rename ok");
- // Rename docs starting with $oldref with $newref
- $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
- foreach($listoffiles as $fileentry)
- {
- $dirsource=$fileentry['name'];
- $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
- $dirsource=$fileentry['path'].'/'.$dirsource;
- $dirdest=$fileentry['path'].'/'.$dirdest;
- @rename($dirsource, $dirdest);
- }
- }
- }
- }
- }
-
- // Set new ref and current status
- if (! $error)
- {
- $this->ref = $num;
- $this->statut = self::STATUS_VALIDATED;
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
+ if (! $error && ! $notrigger)
{
- $this->db->rollback();
- return -1;
- }
- }
+ // Call trigger
+ $result=$this->call_trigger('ORDER_VALIDATE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- /**
- * Set draft status
- *
- * @param User $user Object user that modify
- * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
- * @return int <0 if KO, >0 if OK
- */
- function set_draft($user, $idwarehouse=-1)
- {
- global $conf,$langs;
+ if (! $error)
+ {
+ $this->oldref = $this->ref;
- $error=0;
+ // Rename directory if dir was a temporary ref
+ if (preg_match('/^[\(]?PROV/i', $this->ref))
+ {
+ // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
+ // in order not to lose the attachments
+ $oldref = dol_sanitizeFileName($this->ref);
+ $newref = dol_sanitizeFileName($num);
+ $dirsource = $conf->commande->dir_output.'/'.$oldref;
+ $dirdest = $conf->commande->dir_output.'/'.$newref;
+ if (file_exists($dirsource))
+ {
+ dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
- // Protection
- if ($this->statut <= self::STATUS_DRAFT)
- {
- return 0;
- }
+ if (@rename($dirsource, $dirdest))
+ {
+ dol_syslog("Rename ok");
+ // Rename docs starting with $oldref with $newref
+ $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
+ foreach($listoffiles as $fileentry)
+ {
+ $dirsource=$fileentry['name'];
+ $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
+ $dirsource=$fileentry['path'].'/'.$dirsource;
+ $dirdest=$fileentry['path'].'/'.$dirdest;
+ @rename($dirsource, $dirdest);
+ }
+ }
+ }
+ }
+ }
- if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
- {
- $this->error='Permission denied';
- return -1;
- }
+ // Set new ref and current status
+ if (! $error)
+ {
+ $this->ref = $num;
+ $this->statut = self::STATUS_VALIDATED;
+ }
- $this->db->begin();
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET fk_statut = ".self::STATUS_DRAFT;
- $sql.= " WHERE rowid = ".$this->id;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set draft status
+ *
+ * @param User $user Object user that modify
+ * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_draft($user, $idwarehouse=-1)
+ {
+ //phpcs:enable
+ global $conf,$langs;
- dol_syslog(get_class($this)."::set_draft", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- // If stock is decremented on validate order, we must reincrement it
- if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
- {
- $result = 0;
+ $error=0;
- require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
- $langs->load("agenda");
+ // Protection
+ if ($this->statut <= self::STATUS_DRAFT)
+ {
+ return 0;
+ }
- $num=count($this->lines);
- for ($i = 0; $i < $num; $i++)
- {
- if ($this->lines[$i]->fk_product > 0)
- {
- $mouvP = new MouvementStock($this->db);
- $mouvP->origin = &$this;
- // We increment stock of product (and sub-products)
- $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
- if ($result < 0) { $error++; $this->error=$mouvP->error; break; }
- }
- }
- }
+ if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }
- if (!$error) {
- // Call trigger
- $result=$this->call_trigger('ORDER_UNVALIDATE',$user);
- if ($result < 0) $error++;
- }
+ $this->db->begin();
- if (!$error) {
- $this->statut=self::STATUS_DRAFT;
- $this->db->commit();
- return 1;
- }else {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -1;
- }
- }
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET fk_statut = ".self::STATUS_DRAFT;
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(get_class($this)."::set_draft", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ // If stock is decremented on validate order, we must reincrement it
+ if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
+ {
+ $result = 0;
+
+ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+ $langs->load("agenda");
+
+ $num=count($this->lines);
+ for ($i = 0; $i < $num; $i++)
+ {
+ if ($this->lines[$i]->fk_product > 0)
+ {
+ $mouvP = new MouvementStock($this->db);
+ $mouvP->origin = &$this;
+ // We increment stock of product (and sub-products)
+ $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
+ if ($result < 0) { $error++; $this->error=$mouvP->error; break; }
+ }
+ }
+ }
+
+ if (!$error) {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_UNVALIDATE',$user);
+ if ($result < 0) $error++;
+ }
+
+ if (!$error) {
+ $this->statut=self::STATUS_DRAFT;
+ $this->db->commit();
+ return 1;
+ }else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Tag the order as validated (opened)
- * Function used when order is reopend after being closed.
- *
- * @param User $user Object user that change status
- * @return int <0 if KO, 0 if nothing is done, >0 if OK
- */
- function set_reopen($user)
- {
- $error=0;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Tag the order as validated (opened)
+ * Function used when order is reopend after being closed.
+ *
+ * @param User $user Object user that change status
+ * @return int <0 if KO, 0 if nothing is done, >0 if OK
+ */
+ function set_reopen($user)
+ {
+ // phpcs:enable
+ $error=0;
- if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED)
- {
- dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING);
- return 0;
- }
+ if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED)
+ {
+ dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING);
+ return 0;
+ }
- $this->db->begin();
+ $this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
- $sql.= ' WHERE rowid = '.$this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
+ $sql.= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_REOPEN',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
- else
- {
- $error++;
- $this->error=$this->db->lasterror();
- dol_print_error($this->db);
- }
+ dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_REOPEN',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+ else
+ {
+ $error++;
+ $this->error=$this->db->lasterror();
+ dol_print_error($this->db);
+ }
- if (! $error)
- {
- $this->statut = self::STATUS_VALIDATED;
- $this->billed = 0;
+ if (! $error)
+ {
+ $this->statut = self::STATUS_VALIDATED;
+ $this->billed = 0;
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
- /**
- * Close order
- *
- * @param User $user Objet user that close
- * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function cloture($user, $notrigger=0)
- {
- global $conf;
+ /**
+ * Close order
+ *
+ * @param User $user Objet user that close
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function cloture($user, $notrigger=0)
+ {
+ global $conf;
- $error=0;
+ $error=0;
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
- {
- $this->db->begin();
+ if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
+ {
+ $this->db->begin();
- $now=dol_now();
+ $now=dol_now();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.',';
- $sql.= ' fk_user_cloture = '.$user->id.',';
- $sql.= " date_cloture = '".$this->db->idate($now)."'";
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.',';
+ $sql.= ' fk_user_cloture = '.$user->id.',';
+ $sql.= " date_cloture = '".$this->db->idate($now)."'";
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
- if ($this->db->query($sql))
- {
- if (! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_CLOSE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if ($this->db->query($sql))
+ {
+ if (! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CLOSE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- if (! $error)
- {
- $this->statut=self::STATUS_CLOSED;
+ if (! $error)
+ {
+ $this->statut=self::STATUS_CLOSED;
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->db->lasterror();
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
- $this->db->rollback();
- return -1;
- }
- }
- return 0;
- }
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ return 0;
+ }
- /**
- * Cancel an order
- * If stock is decremented on order validation, we must reincrement it
- *
- * @param int $idwarehouse Id warehouse to use for stock change.
- * @return int <0 if KO, >0 if OK
- */
+ /**
+ * Cancel an order
+ * If stock is decremented on order validation, we must reincrement it
+ *
+ * @param int $idwarehouse Id warehouse to use for stock change.
+ * @return int <0 if KO, >0 if OK
+ */
function cancel($idwarehouse=-1)
{
global $conf,$user,$langs;
@@ -670,10 +703,10 @@ class Commande extends CommonOrder
if (! $error)
{
- // Call trigger
- $result=$this->call_trigger('ORDER_CANCEL',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CANCEL',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
if (! $error)
@@ -701,24 +734,24 @@ class Commande extends CommonOrder
}
}
- /**
- * Create order
- * Note that this->ref can be set or empty. If empty, we will use "(PROV)"
- *
- * @param User $user Objet user that make creation
- * @param int $notrigger Disable all triggers
- * @return int <0 if KO, >0 if OK
- */
- function create($user, $notrigger=0)
- {
- global $conf,$langs;
- $error=0;
+ /**
+ * Create order
+ * Note that this->ref can be set or empty. If empty, we will use "(PROV)"
+ *
+ * @param User $user Objet user that make creation
+ * @param int $notrigger Disable all triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function create($user, $notrigger=0)
+ {
+ global $conf,$langs;
+ $error=0;
- // Clean parameters
- $this->brouillon = 1; // set command as draft
+ // Clean parameters
+ $this->brouillon = 1; // set command as draft
// $date_commande is deprecated
- $date = ($this->date_commande ? $this->date_commande : $this->date);
+ $date = ($this->date_commande ? $this->date_commande : $this->date);
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date);
@@ -730,412 +763,412 @@ class Commande extends CommonOrder
$this->multicurrency_tx = 1;
}
- dol_syslog(get_class($this)."::create user=".$user->id);
+ dol_syslog(get_class($this)."::create user=".$user->id);
- // Check parameters
- if (! empty($this->ref)) // We check that ref is not already used
- {
- $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
- if ($result > 0)
- {
- $this->error='ErrorRefAlreadyExists';
- dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING);
- $this->db->rollback();
- return -1;
- }
- }
+ // Check parameters
+ if (! empty($this->ref)) // We check that ref is not already used
+ {
+ $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
+ if ($result > 0)
+ {
+ $this->error='ErrorRefAlreadyExists';
+ dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING);
+ $this->db->rollback();
+ return -1;
+ }
+ }
- $soc = new Societe($this->db);
- $result=$soc->fetch($this->socid);
- if ($result < 0)
- {
- $this->error="Failed to fetch company";
- dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
- return -2;
- }
- if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0)
- {
- $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
- dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
- return -1;
- }
+ $soc = new Societe($this->db);
+ $result=$soc->fetch($this->socid);
+ if ($result < 0)
+ {
+ $this->error="Failed to fetch company";
+ dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
+ return -2;
+ }
+ if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0)
+ {
+ $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
+ dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
+ return -1;
+ }
- $now=dol_now();
+ $now=dol_now();
- $this->db->begin();
+ $this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
- $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int";
- $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
- $sql.= ", fk_shipping_method";
- $sql.= ", fk_warehouse";
- $sql.= ", remise_absolue, remise_percent";
- $sql.= ", fk_incoterms, location_incoterms";
- $sql.= ", entity";
- $sql.= ", fk_multicurrency";
- $sql.= ", multicurrency_code";
- $sql.= ", multicurrency_tx";
- $sql.= ")";
- $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
- $sql.= ", ".($this->fk_project>0?$this->fk_project:"null");
- $sql.= ", '".$this->db->idate($date)."'";
- $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null');
- $sql.= ", '".$this->db->escape($this->note_private)."'";
- $sql.= ", '".$this->db->escape($this->note_public)."'";
- $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
- $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
- $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
- $sql.= ", '".$this->db->escape($this->modelpdf)."'";
- $sql.= ", ".($this->cond_reglement_id>0?$this->cond_reglement_id:"null");
- $sql.= ", ".($this->mode_reglement_id>0?$this->mode_reglement_id:"null");
- $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
- $sql.= ", ".($this->availability_id>0?$this->availability_id:"null");
- $sql.= ", ".($this->demand_reason_id>0?$this->demand_reason_id:"null");
- $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
- $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL');
- $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
- $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL');
- $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL');
- $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
- $sql.= ", ".(int) $this->fk_incoterms;
- $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
- $sql.= ", ".$conf->entity;
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
+ $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int";
+ $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
+ $sql.= ", fk_shipping_method";
+ $sql.= ", fk_warehouse";
+ $sql.= ", remise_absolue, remise_percent";
+ $sql.= ", fk_incoterms, location_incoterms";
+ $sql.= ", entity";
+ $sql.= ", fk_multicurrency";
+ $sql.= ", multicurrency_code";
+ $sql.= ", multicurrency_tx";
+ $sql.= ")";
+ $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
+ $sql.= ", ".($this->fk_project>0?$this->fk_project:"null");
+ $sql.= ", '".$this->db->idate($date)."'";
+ $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null');
+ $sql.= ", '".$this->db->escape($this->note_private)."'";
+ $sql.= ", '".$this->db->escape($this->note_public)."'";
+ $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
+ $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
+ $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
+ $sql.= ", '".$this->db->escape($this->modelpdf)."'";
+ $sql.= ", ".($this->cond_reglement_id>0?$this->cond_reglement_id:"null");
+ $sql.= ", ".($this->mode_reglement_id>0?$this->mode_reglement_id:"null");
+ $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
+ $sql.= ", ".($this->availability_id>0?$this->availability_id:"null");
+ $sql.= ", ".($this->demand_reason_id>0?$this->demand_reason_id:"null");
+ $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
+ $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL');
+ $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
+ $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL');
+ $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL');
+ $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
+ $sql.= ", ".$conf->entity;
$sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx;
- $sql.= ")";
+ $sql.= ")";
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande');
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande');
- if ($this->id)
- {
- $fk_parent_line=0;
- $num=count($this->lines);
+ if ($this->id)
+ {
+ $fk_parent_line=0;
+ $num=count($this->lines);
- /*
- * Insert products details into db
- */
- for ($i=0;$i<$num;$i++)
- {
- $line = $this->lines[$i];
+ /*
+ * Insert products details into db
+ */
+ for ($i=0;$i<$num;$i++)
+ {
+ $line = $this->lines[$i];
- // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
- //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object.
- if (! is_object($line)) $line = (object) $line;
+ // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
+ //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object.
+ if (! is_object($line)) $line = (object) $line;
- // Reset fk_parent_line for no child products and special product
- if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
- $fk_parent_line = 0;
- }
+ // Reset fk_parent_line for no child products and special product
+ if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
+ $fk_parent_line = 0;
+ }
// Complete vat rate with code
$vatrate = $line->tva_tx;
if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')';
- $result = $this->addline(
- $line->desc,
- $line->subprice,
- $line->qty,
- $vatrate,
- $line->localtax1_tx,
- $line->localtax2_tx,
- $line->fk_product,
- $line->remise_percent,
- $line->info_bits,
- $line->fk_remise_except,
- 'HT',
- 0,
- $line->date_start,
- $line->date_end,
- $line->product_type,
- $line->rang,
- $line->special_code,
- $fk_parent_line,
- $line->fk_fournprice,
- $line->pa_ht,
- $line->label,
- $line->array_options,
- $line->fk_unit,
- $this->element,
- $line->id
- );
- if ($result < 0)
- {
- if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER)
- {
- $this->error=$this->db->lasterror();
- dol_print_error($this->db);
- }
- $this->db->rollback();
- return -1;
- }
- // Defined the new fk_parent_line
- if ($result > 0 && $line->product_type == 9) {
- $fk_parent_line = $result;
- }
- }
-
- // update ref
- $initialref='(PROV'.$this->id.')';
- if (! empty($this->ref)) $initialref=$this->ref;
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
- if ($this->db->query($sql))
- {
- if ($this->id)
- {
- $this->ref = $initialref;
-
- if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
- {
- $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
- }
-
- // Add object linked
- if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
- {
- foreach($this->linked_objects as $origin => $tmp_origin_id)
- {
- if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
- {
- foreach($tmp_origin_id as $origin_id)
- {
- $ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- }
- else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
- {
- $origin_id = $tmp_origin_id;
- $ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- }
- }
-
- if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object
- {
- $originforcontact = $this->origin;
- $originidforcontact = $this->origin_id;
- if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
- {
- require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
- $exp = new Expedition($this->db);
- $exp->fetch($this->origin_id);
- $exp->fetchObjectLinked();
- if (count($exp->linkedObjectsIds['commande']) > 0)
- {
- foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
- {
- $originforcontact = 'commande';
- if (is_object($value)) $originidforcontact = $value->id;
- else $originidforcontact = $value;
- break; // We take first one
- }
- }
- }
-
- $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
- $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
-
- $resqlcontact = $this->db->query($sqlcontact);
- if ($resqlcontact)
- {
- while($objcontact = $this->db->fetch_object($resqlcontact))
- {
- //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
- $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
- }
- }
- else dol_print_error($resqlcontact);
- }
- }
-
- if (! $error)
- {
- $result=$this->insertExtraFields();
- if ($result < 0) $error++;
- }
-
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_CREATE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return $this->id;
- }
- else
+ $result = $this->addline(
+ $line->desc,
+ $line->subprice,
+ $line->qty,
+ $vatrate,
+ $line->localtax1_tx,
+ $line->localtax2_tx,
+ $line->fk_product,
+ $line->remise_percent,
+ $line->info_bits,
+ $line->fk_remise_except,
+ 'HT',
+ 0,
+ $line->date_start,
+ $line->date_end,
+ $line->product_type,
+ $line->rang,
+ $line->special_code,
+ $fk_parent_line,
+ $line->fk_fournprice,
+ $line->pa_ht,
+ $line->label,
+ $line->array_options,
+ $line->fk_unit,
+ $this->element,
+ $line->id
+ );
+ if ($result < 0)
{
- $this->db->rollback();
- return -1*$error;
+ if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER)
+ {
+ $this->error=$this->db->lasterror();
+ dol_print_error($this->db);
+ }
+ $this->db->rollback();
+ return -1;
}
- }
- else
+ // Defined the new fk_parent_line
+ if ($result > 0 && $line->product_type == 9) {
+ $fk_parent_line = $result;
+ }
+ }
+
+ // update ref
+ $initialref='(PROV'.$this->id.')';
+ if (! empty($this->ref)) $initialref=$this->ref;
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
+ if ($this->db->query($sql))
+ {
+ if ($this->id)
+ {
+ $this->ref = $initialref;
+
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ }
+
+ if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object
+ {
+ $originforcontact = $this->origin;
+ $originidforcontact = $this->origin_id;
+ if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
+ {
+ require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
+ $exp = new Expedition($this->db);
+ $exp->fetch($this->origin_id);
+ $exp->fetchObjectLinked();
+ if (count($exp->linkedObjectsIds['commande']) > 0)
+ {
+ foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
+ {
+ $originforcontact = 'commande';
+ if (is_object($value)) $originidforcontact = $value->id;
+ else $originidforcontact = $value;
+ break; // We take first one
+ }
+ }
+ }
+
+ $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
+ $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
+
+ $resqlcontact = $this->db->query($sqlcontact);
+ if ($resqlcontact)
+ {
+ while($objcontact = $this->db->fetch_object($resqlcontact))
+ {
+ //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
+ $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
+ }
+ }
+ else dol_print_error($resqlcontact);
+ }
+ }
+
+ if (! $error)
+ {
+ $result=$this->insertExtraFields();
+ if ($result < 0) $error++;
+ }
+
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CREATE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
{
$this->error=$this->db->lasterror();
- $this->db->rollback();
- return -1;
- }
- }
- }
- else
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ }
+ else
{
- dol_print_error($this->db);
- $this->db->rollback();
- return -1;
- }
- }
+ dol_print_error($this->db);
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Load an object from its id and create a new one in database
- *
- * @param int $socid Id of thirdparty
- * @return int New id of clone
- */
- function createFromClone($socid=0)
- {
- global $user,$hookmanager;
+ /**
+ * Load an object from its id and create a new one in database
+ *
+ * @param int $socid Id of thirdparty
+ * @return int New id of clone
+ */
+ function createFromClone($socid=0)
+ {
+ global $user,$hookmanager;
- $error=0;
+ $error=0;
- $this->context['createfromclone'] = 'createfromclone';
+ $this->context['createfromclone'] = 'createfromclone';
- $this->db->begin();
+ $this->db->begin();
// get lines so they will be clone
foreach($this->lines as $line)
$line->fetch_optionals();
- // Load source object
- $objFrom = clone $this;
+ // Load source object
+ $objFrom = clone $this;
- // Change socid if needed
- if (! empty($socid) && $socid != $this->socid)
- {
- $objsoc = new Societe($this->db);
+ // Change socid if needed
+ if (! empty($socid) && $socid != $this->socid)
+ {
+ $objsoc = new Societe($this->db);
- if ($objsoc->fetch($socid)>0)
- {
- $this->socid = $objsoc->id;
- $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
- $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
- $this->fk_project = 0;
- $this->fk_delivery_address = 0;
- }
+ if ($objsoc->fetch($socid)>0)
+ {
+ $this->socid = $objsoc->id;
+ $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
+ $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
+ $this->fk_project = 0;
+ $this->fk_delivery_address = 0;
+ }
- // TODO Change product price if multi-prices
- }
+ // TODO Change product price if multi-prices
+ }
- $this->id=0;
- $this->ref = '';
- $this->statut=self::STATUS_DRAFT;
+ $this->id=0;
+ $this->ref = '';
+ $this->statut=self::STATUS_DRAFT;
- // Clear fields
- $this->user_author_id = $user->id;
- $this->user_valid = '';
- $this->date = dol_now();
- $this->date_commande = dol_now();
- $this->date_creation = '';
- $this->date_validation = '';
- $this->ref_client = '';
+ // Clear fields
+ $this->user_author_id = $user->id;
+ $this->user_valid = '';
+ $this->date = dol_now();
+ $this->date_commande = dol_now();
+ $this->date_creation = '';
+ $this->date_validation = '';
+ $this->ref_client = '';
- // Create clone
- $result=$this->create($user);
- if ($result < 0) $error++;
+ // Create clone
+ $result=$this->create($user);
+ if ($result < 0) $error++;
- if (! $error)
- {
- // Hook of thirdparty module
- if (is_object($hookmanager))
- {
- $parameters=array('objFrom'=>$objFrom);
- $action='';
- $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
- }
- }
+ if (! $error)
+ {
+ // Hook of thirdparty module
+ if (is_object($hookmanager))
+ {
+ $parameters=array('objFrom'=>$objFrom);
+ $action='';
+ $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) $error++;
+ }
+ }
- unset($this->context['createfromclone']);
+ unset($this->context['createfromclone']);
- // End
- if (! $error)
- {
- $this->db->commit();
- return $this->id;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
+ // End
+ if (! $error)
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Load an object from a proposal and create a new order into database
- *
- * @param Object $object Object source
- * @param User $user User making creation
- * @return int <0 if KO, 0 if nothing done, 1 if OK
- */
- function createFromProposal($object, User $user)
- {
- global $conf, $hookmanager;
+ /**
+ * Load an object from a proposal and create a new order into database
+ *
+ * @param Object $object Object source
+ * @param User $user User making creation
+ * @return int <0 if KO, 0 if nothing done, 1 if OK
+ */
+ function createFromProposal($object, User $user)
+ {
+ global $conf, $hookmanager;
dol_include_once('/core/class/extrafields.class.php');
- $error=0;
+ $error=0;
- $this->date_commande = dol_now();
- $this->source = 0;
+ $this->date_commande = dol_now();
+ $this->source = 0;
- $num=count($object->lines);
- for ($i = 0; $i < $num; $i++)
- {
- $line = new OrderLine($this->db);
+ $num=count($object->lines);
+ for ($i = 0; $i < $num; $i++)
+ {
+ $line = new OrderLine($this->db);
- $line->libelle = $object->lines[$i]->libelle;
- $line->label = $object->lines[$i]->label;
- $line->desc = $object->lines[$i]->desc;
- $line->price = $object->lines[$i]->price;
- $line->subprice = $object->lines[$i]->subprice;
- $line->vat_src_code = $object->lines[$i]->vat_src_code;
- $line->tva_tx = $object->lines[$i]->tva_tx;
- $line->localtax1_tx = $object->lines[$i]->localtax1_tx;
- $line->localtax2_tx = $object->lines[$i]->localtax2_tx;
- $line->qty = $object->lines[$i]->qty;
- $line->fk_remise_except = $object->lines[$i]->fk_remise_except;
- $line->remise_percent = $object->lines[$i]->remise_percent;
- $line->fk_product = $object->lines[$i]->fk_product;
- $line->info_bits = $object->lines[$i]->info_bits;
- $line->product_type = $object->lines[$i]->product_type;
- $line->rang = $object->lines[$i]->rang;
- $line->special_code = $object->lines[$i]->special_code;
- $line->fk_parent_line = $object->lines[$i]->fk_parent_line;
- $line->fk_unit = $object->lines[$i]->fk_unit;
+ $line->libelle = $object->lines[$i]->libelle;
+ $line->label = $object->lines[$i]->label;
+ $line->desc = $object->lines[$i]->desc;
+ $line->price = $object->lines[$i]->price;
+ $line->subprice = $object->lines[$i]->subprice;
+ $line->vat_src_code = $object->lines[$i]->vat_src_code;
+ $line->tva_tx = $object->lines[$i]->tva_tx;
+ $line->localtax1_tx = $object->lines[$i]->localtax1_tx;
+ $line->localtax2_tx = $object->lines[$i]->localtax2_tx;
+ $line->qty = $object->lines[$i]->qty;
+ $line->fk_remise_except = $object->lines[$i]->fk_remise_except;
+ $line->remise_percent = $object->lines[$i]->remise_percent;
+ $line->fk_product = $object->lines[$i]->fk_product;
+ $line->info_bits = $object->lines[$i]->info_bits;
+ $line->product_type = $object->lines[$i]->product_type;
+ $line->rang = $object->lines[$i]->rang;
+ $line->special_code = $object->lines[$i]->special_code;
+ $line->fk_parent_line = $object->lines[$i]->fk_parent_line;
+ $line->fk_unit = $object->lines[$i]->fk_unit;
- $line->date_start = $object->lines[$i]->date_start;
- $line->date_end = $object->lines[$i]->date_end;
+ $line->date_start = $object->lines[$i]->date_start;
+ $line->date_end = $object->lines[$i]->date_end;
$line->fk_fournprice = $object->lines[$i]->fk_fournprice;
$marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht);
@@ -1143,34 +1176,34 @@ class Commande extends CommonOrder
$line->marge_tx = $marginInfos[1];
$line->marque_tx = $marginInfos[2];
- // get extrafields from original line
+ // get extrafields from original line
$object->lines[$i]->fetch_optionals();
foreach($object->lines[$i]->array_options as $options_key => $value)
$line->array_options[$options_key] = $value;
- $this->lines[$i] = $line;
- }
+ $this->lines[$i] = $line;
+ }
- $this->socid = $object->socid;
- $this->fk_project = $object->fk_project;
- $this->cond_reglement_id = $object->cond_reglement_id;
- $this->mode_reglement_id = $object->mode_reglement_id;
- $this->fk_account = $object->fk_account;
- $this->availability_id = $object->availability_id;
- $this->demand_reason_id = $object->demand_reason_id;
- $this->date_livraison = $object->date_livraison;
- $this->shipping_method_id = $object->shipping_method_id;
- $this->warehouse_id = $object->warehouse_id;
- $this->fk_delivery_address = $object->fk_delivery_address;
- $this->contact_id = $object->contactid;
- $this->ref_client = $object->ref_client;
- $this->note_private = $object->note_private;
- $this->note_public = $object->note_public;
+ $this->socid = $object->socid;
+ $this->fk_project = $object->fk_project;
+ $this->cond_reglement_id = $object->cond_reglement_id;
+ $this->mode_reglement_id = $object->mode_reglement_id;
+ $this->fk_account = $object->fk_account;
+ $this->availability_id = $object->availability_id;
+ $this->demand_reason_id = $object->demand_reason_id;
+ $this->date_livraison = $object->date_livraison;
+ $this->shipping_method_id = $object->shipping_method_id;
+ $this->warehouse_id = $object->warehouse_id;
+ $this->fk_delivery_address = $object->fk_delivery_address;
+ $this->contact_id = $object->contactid;
+ $this->ref_client = $object->ref_client;
+ $this->note_private = $object->note_private;
+ $this->note_public = $object->note_public;
- $this->origin = $object->element;
- $this->origin_id = $object->id;
+ $this->origin = $object->element;
+ $this->origin_id = $object->id;
- // get extrafields from original line
+ // get extrafields from original line
$object->fetch_optionals($object->id);
$e = new ExtraFields($this->db);
@@ -1181,129 +1214,129 @@ class Commande extends CommonOrder
$this->array_options[$options_key] = $value;
}
}
- // Possibility to add external linked objects with hooks
- $this->linked_objects[$this->origin] = $this->origin_id;
- if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
- {
- $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
- }
+ // Possibility to add external linked objects with hooks
+ $this->linked_objects[$this->origin] = $this->origin_id;
+ if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
+ {
+ $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
+ }
- $ret = $this->create($user);
+ $ret = $this->create($user);
- if ($ret > 0)
- {
- // Actions hooked (by external module)
- $hookmanager->initHooks(array('orderdao'));
+ if ($ret > 0)
+ {
+ // Actions hooked (by external module)
+ $hookmanager->initHooks(array('orderdao'));
- $parameters=array('objFrom'=>$object);
- $action='';
- $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
+ $parameters=array('objFrom'=>$object);
+ $action='';
+ $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) $error++;
- if (! $error)
- {
- // Ne pas passer par la commande provisoire
- if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
- {
- $this->fetch($ret);
- $this->valid($user);
- }
- return $ret;
- }
- else return -1;
- }
- else return -1;
- }
+ if (! $error)
+ {
+ // Ne pas passer par la commande provisoire
+ if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
+ {
+ $this->fetch($ret);
+ $this->valid($user);
+ }
+ return $ret;
+ }
+ else return -1;
+ }
+ else return -1;
+ }
- /**
- * Add an order line into database (linked to product/service or not)
- *
- * @param string $desc Description of line
- * @param float $pu_ht Unit price (without tax)
- * @param float $qty Quantite
- * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
- * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
- * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
- * @param int $fk_product Id of product
- * @param float $remise_percent Pourcentage de remise de la ligne
- * @param int $info_bits Bits de type de lignes
- * @param int $fk_remise_except Id remise
- * @param string $price_base_type HT or TTC
- * @param float $pu_ttc Prix unitaire TTC
- * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
- * @param int $rang Position of line
- * @param int $special_code Special code (also used by externals modules!)
- * @param int $fk_parent_line Parent line
- * @param int $fk_fournprice Id supplier price
- * @param int $pa_ht Buying price (without tax)
- * @param string $label Label
+ /**
+ * Add an order line into database (linked to product/service or not)
+ *
+ * @param string $desc Description of line
+ * @param float $pu_ht Unit price (without tax)
+ * @param float $qty Quantite
+ * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
+ * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
+ * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
+ * @param int $fk_product Id of product
+ * @param float $remise_percent Pourcentage de remise de la ligne
+ * @param int $info_bits Bits de type de lignes
+ * @param int $fk_remise_except Id remise
+ * @param string $price_base_type HT or TTC
+ * @param float $pu_ttc Prix unitaire TTC
+ * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
+ * @param int $rang Position of line
+ * @param int $special_code Special code (also used by externals modules!)
+ * @param int $fk_parent_line Parent line
+ * @param int $fk_fournprice Id supplier price
+ * @param int $pa_ht Buying price (without tax)
+ * @param string $label Label
* @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
- * @param string $fk_unit Code of the unit to use. Null to use the default one
- * @param string $origin 'order', ...
- * @param int $origin_id Id of origin object
+ * @param string $fk_unit Code of the unit to use. Null to use the default one
+ * @param string $origin 'order', ...
+ * @param int $origin_id Id of origin object
* @param double $pu_ht_devise Unit price in currency
- * @return int >0 if OK, <0 if KO
- *
- * @see add_product
- *
- * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
- * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
- * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
- * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
- */
+ * @return int >0 if OK, <0 if KO
+ *
+ * @see add_product
+ *
+ * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
+ * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
+ * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
+ * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
+ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0)
- {
- global $mysoc, $conf, $langs, $user;
+ {
+ global $mysoc, $conf, $langs, $user;
$logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent";
$logtext.= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start";
$logtext.= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise";
- dol_syslog(get_class($this).$logtext, LOG_DEBUG);
+ dol_syslog(get_class($this).$logtext, LOG_DEBUG);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- // Clean parameters
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($rang)) $rang=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
- if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
- if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
+ // Clean parameters
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($rang)) $rang=0;
+ if (empty($txtva)) $txtva=0;
+ if (empty($txlocaltax1)) $txlocaltax1=0;
+ if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
+ if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu_ht=price2num($pu_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $pu_ttc=price2num($pu_ttc);
- $pa_ht=price2num($pa_ht);
- $txtva = price2num($txtva);
- $txlocaltax1 = price2num($txlocaltax1);
- $txlocaltax2 = price2num($txlocaltax2);
- if ($price_base_type=='HT')
- {
- $pu=$pu_ht;
- }
- else
- {
- $pu=$pu_ttc;
- }
- $label=trim($label);
- $desc=trim($desc);
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu_ht=price2num($pu_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $pu_ttc=price2num($pu_ttc);
+ $pa_ht=price2num($pa_ht);
+ $txtva = price2num($txtva);
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
+ if ($price_base_type=='HT')
+ {
+ $pu=$pu_ht;
+ }
+ else
+ {
+ $pu=$pu_ttc;
+ }
+ $label=trim($label);
+ $desc=trim($desc);
- // Check parameters
- if ($type < 0) return -1;
+ // Check parameters
+ if ($type < 0) return -1;
- if ($this->statut == self::STATUS_DRAFT)
- {
- $this->db->begin();
+ if ($this->statut == self::STATUS_DRAFT)
+ {
+ $this->db->begin();
- $product_type=$type;
+ $product_type=$type;
if (!empty($fk_product))
{
$product=new Product($this->db);
@@ -1312,105 +1345,105 @@ class Commande extends CommonOrder
if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
{
- $langs->load("errors");
- $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
$this->db->rollback();
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
}
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
- // qty, pu, remise_percent et txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
+ $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
- // Clean vat code
- $vat_src_code='';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- /*var_dump($txlocaltax1);
- var_dump($txlocaltax2);
- var_dump($localtaxes_type);
- var_dump($tabprice);
- var_dump($tabprice[9]);
- var_dump($tabprice[10]);
- exit;*/
+ /*var_dump($txlocaltax1);
+ var_dump($txlocaltax2);
+ var_dump($localtaxes_type);
+ var_dump($tabprice);
+ var_dump($tabprice[9]);
+ var_dump($tabprice[10]);
+ exit;*/
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
- // Rang to use
- $rangtouse = $rang;
- if ($rangtouse == -1)
- {
- $rangmax = $this->line_max($fk_parent_line);
- $rangtouse = $rangmax + 1;
- }
+ // Rang to use
+ $rangtouse = $rang;
+ if ($rangtouse == -1)
+ {
+ $rangmax = $this->line_max($fk_parent_line);
+ $rangtouse = $rangmax + 1;
+ }
- // TODO A virer
- // Anciens indicateurs: $price, $remise (a ne plus utiliser)
- $price = $pu;
- $remise = 0;
- if ($remise_percent > 0)
- {
- $remise = round(($pu * $remise_percent / 100), 2);
- $price = $pu - $remise;
- }
+ // TODO A virer
+ // Anciens indicateurs: $price, $remise (a ne plus utiliser)
+ $price = $pu;
+ $remise = 0;
+ if ($remise_percent > 0)
+ {
+ $remise = round(($pu * $remise_percent / 100), 2);
+ $price = $pu - $remise;
+ }
- // Insert line
- $this->line=new OrderLine($this->db);
+ // Insert line
+ $this->line=new OrderLine($this->db);
- $this->line->context = $this->context;
+ $this->line->context = $this->context;
- $this->line->fk_commande=$this->id;
- $this->line->label=$label;
- $this->line->desc=$desc;
- $this->line->qty=$qty;
+ $this->line->fk_commande=$this->id;
+ $this->line->label=$label;
+ $this->line->desc=$desc;
+ $this->line->qty=$qty;
- $this->line->vat_src_code=$vat_src_code;
- $this->line->tva_tx=$txtva;
- $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
- $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
- $this->line->localtax1_type=$localtaxes_type[0];
- $this->line->localtax2_type=$localtaxes_type[2];
- $this->line->fk_product=$fk_product;
+ $this->line->vat_src_code=$vat_src_code;
+ $this->line->tva_tx=$txtva;
+ $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
+ $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
+ $this->line->localtax1_type=$localtaxes_type[0];
+ $this->line->localtax2_type=$localtaxes_type[2];
+ $this->line->fk_product=$fk_product;
$this->line->product_type=$product_type;
- $this->line->fk_remise_except=$fk_remise_except;
- $this->line->remise_percent=$remise_percent;
- $this->line->subprice=$pu_ht;
- $this->line->rang=$rangtouse;
- $this->line->info_bits=$info_bits;
- $this->line->total_ht=$total_ht;
- $this->line->total_tva=$total_tva;
- $this->line->total_localtax1=$total_localtax1;
- $this->line->total_localtax2=$total_localtax2;
- $this->line->total_ttc=$total_ttc;
- $this->line->special_code=$special_code;
- $this->line->origin=$origin;
- $this->line->origin_id=$origin_id;
- $this->line->fk_parent_line=$fk_parent_line;
- $this->line->fk_unit=$fk_unit;
+ $this->line->fk_remise_except=$fk_remise_except;
+ $this->line->remise_percent=$remise_percent;
+ $this->line->subprice=$pu_ht;
+ $this->line->rang=$rangtouse;
+ $this->line->info_bits=$info_bits;
+ $this->line->total_ht=$total_ht;
+ $this->line->total_tva=$total_tva;
+ $this->line->total_localtax1=$total_localtax1;
+ $this->line->total_localtax2=$total_localtax2;
+ $this->line->total_ttc=$total_ttc;
+ $this->line->special_code=$special_code;
+ $this->line->origin=$origin;
+ $this->line->origin_id=$origin_id;
+ $this->line->fk_parent_line=$fk_parent_line;
+ $this->line->fk_unit=$fk_unit;
- $this->line->date_start=$date_start;
- $this->line->date_end=$date_end;
+ $this->line->date_start=$date_start;
+ $this->line->date_end=$date_end;
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
@@ -1420,185 +1453,190 @@ class Commande extends CommonOrder
$this->line->multicurrency_code = $this->multicurrency_code;
$this->line->multicurrency_subprice = $pu_ht_devise;
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
- $this->line->multicurrency_total_tva = $multicurrency_total_tva;
- $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
+ $this->line->multicurrency_total_tva = $multicurrency_total_tva;
+ $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
- // TODO Ne plus utiliser
- $this->line->price=$price;
- $this->line->remise=$remise;
+ // TODO Ne plus utiliser
+ $this->line->price=$price;
+ $this->line->remise=$remise;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
- $result=$this->line->insert($user);
- if ($result > 0)
- {
- // Reorder if child line
- if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
+ $result=$this->line->insert($user);
+ if ($result > 0)
+ {
+ // Reorder if child line
+ if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
- // Mise a jour informations denormalisees au niveau de la commande meme
- $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
- if ($result > 0)
- {
- $this->db->commit();
- return $this->line->rowid;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->line->error;
- dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR);
- $this->db->rollback();
- return -2;
- }
- }
+ // Mise a jour informations denormalisees au niveau de la commande meme
+ $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return $this->line->rowid;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->line->error;
+ dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -2;
+ }
+ }
else
{
- dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
+ dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
return -3;
- }
- }
+ }
+ }
- /**
- * Add line into array
- * $this->client must be loaded
- *
- * @param int $idproduct Product Id
- * @param float $qty Quantity
- * @param float $remise_percent Product discount relative
- * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @return void
- *
- * TODO Remplacer les appels a cette fonction par generation objet Ligne
- * insere dans tableau $this->products
- */
- function add_product($idproduct, $qty, $remise_percent=0.0, $date_start='', $date_end='')
- {
- global $conf, $mysoc;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Add line into array
+ * $this->client must be loaded
+ *
+ * @param int $idproduct Product Id
+ * @param float $qty Quantity
+ * @param float $remise_percent Product discount relative
+ * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @return void
+ *
+ * TODO Remplacer les appels a cette fonction par generation objet Ligne
+ * insere dans tableau $this->products
+ */
+ function add_product($idproduct, $qty, $remise_percent=0.0, $date_start='', $date_end='')
+ {
+ // phpcs:enable
+ global $conf, $mysoc;
- if (! $qty) $qty = 1;
+ if (! $qty) $qty = 1;
- if ($idproduct > 0)
- {
- $prod=new Product($this->db);
- $prod->fetch($idproduct);
+ if ($idproduct > 0)
+ {
+ $prod=new Product($this->db);
+ $prod->fetch($idproduct);
- $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id);
- $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id);
- if (empty($tva_tx)) $tva_npr=0;
- $vat_src_code = ''; // May be defined into tva_tx
+ $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id);
+ $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id);
+ if (empty($tva_tx)) $tva_npr=0;
+ $vat_src_code = ''; // May be defined into tva_tx
- $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr);
- $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr);
+ $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr);
+ $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr);
- // multiprix
- if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level)
- $price = $prod->multiprices[$this->thirdparty->price_level];
- else
- $price = $prod->price;
+ // multiprix
+ if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) {
+ $price = $prod->multiprices[$this->thirdparty->price_level];
+ } else {
+ $price = $prod->price;
+ }
- $line=new OrderLine($this->db);
+ $line=new OrderLine($this->db);
- $line->context = $this->context;
+ $line->context = $this->context;
- $line->fk_product=$idproduct;
- $line->desc=$prod->description;
- $line->qty=$qty;
- $line->subprice=$price;
- $line->remise_percent=$remise_percent;
- $line->vat_src_code=$vat_src_code;
- $line->tva_tx=$tva_tx;
- $line->localtax1_tx=$localtax1_tx;
- $line->localtax2_tx=$localtax2_tx;
- $line->ref=$prod->ref;
- $line->libelle=$prod->label;
- $line->product_desc=$prod->description;
- $line->fk_unit=$prod->fk_unit;
+ $line->fk_product=$idproduct;
+ $line->desc=$prod->description;
+ $line->qty=$qty;
+ $line->subprice=$price;
+ $line->remise_percent=$remise_percent;
+ $line->vat_src_code=$vat_src_code;
+ $line->tva_tx=$tva_tx;
+ $line->localtax1_tx=$localtax1_tx;
+ $line->localtax2_tx=$localtax2_tx;
+ $line->ref=$prod->ref;
+ $line->libelle=$prod->label;
+ $line->product_desc=$prod->description;
+ $line->fk_unit=$prod->fk_unit;
- // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- // Save the start and end date of the line in the object
- if ($date_start) { $line->date_start = $date_start; }
- if ($date_end) { $line->date_end = $date_end; }
+ // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ // Save the start and end date of the line in the object
+ if ($date_start) { $line->date_start = $date_start; }
+ if ($date_end) { $line->date_end = $date_end; }
- $this->lines[] = $line;
+ $this->lines[] = $line;
- /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
- if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
- {
- $prod = new Product($this->db);
- $prod->fetch($idproduct);
- $prod -> get_sousproduits_arbo();
- $prods_arbo = $prod->get_arbo_each_prod();
- if(count($prods_arbo) > 0)
- {
- foreach($prods_arbo as $key => $value)
- {
- // print "id : ".$value[1].' :qty: '.$value[0].' ';
- if(! in_array($value[1],$this->products))
- $this->add_product($value[1], $value[0]);
+ /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
+ if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ {
+ $prod = new Product($this->db);
+ $prod->fetch($idproduct);
+ $prod -> get_sousproduits_arbo();
+ $prods_arbo = $prod->get_arbo_each_prod();
+ if(count($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
+ {
+ // print "id : ".$value[1].' :qty: '.$value[0].' ';
+ if(! in_array($value[1],$this->products))
+ $this->add_product($value[1], $value[0]);
- }
- }
+ }
+ }
- }
- **/
- }
- }
+ }
+ **/
+ }
+ }
- /**
- * Get object and lines from database
- *
- * @param int $id Id of object to load
- * @param string $ref Ref of object
- * @param string $ref_ext External reference of object
- * @param string $ref_int Internal reference of other object
- * @return int >0 if OK, <0 if KO, 0 if not found
- */
- function fetch($id, $ref='', $ref_ext='', $ref_int='')
- {
+ /**
+ * Get object and lines from database
+ *
+ * @param int $id Id of object to load
+ * @param string $ref Ref of object
+ * @param string $ref_ext External reference of object
+ * @param string $ref_int Internal reference of other object
+ * @return int >0 if OK, <0 if KO, 0 if not found
+ */
+ function fetch($id, $ref='', $ref_ext='', $ref_int='')
+ {
- // Check parameters
- if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
+ // Check parameters
+ if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
- $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
- $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
- $sql.= ', c.fk_account';
- $sql.= ', c.date_commande';
- $sql.= ', c.date_livraison';
- $sql.= ', c.fk_shipping_method';
- $sql.= ', c.fk_warehouse';
- $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
- $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams';
- $sql.= ', c.fk_incoterms, c.location_incoterms';
+ $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
+ $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
+ $sql.= ', c.fk_account';
+ $sql.= ', c.date_commande';
+ $sql.= ', c.date_livraison';
+ $sql.= ', c.fk_shipping_method';
+ $sql.= ', c.fk_warehouse';
+ $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
+ $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams';
+ $sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
- $sql.= ", i.libelle as libelle_incoterms";
- $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
- $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
- $sql.= ', ca.code as availability_code, ca.label as availability_label';
- $sql.= ', dr.code as demand_reason_code';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
+ $sql.= ", i.libelle as libelle_incoterms";
+ $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
+ $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
+ $sql.= ', ca.code as availability_code, ca.label as availability_label';
+ $sql.= ', dr.code as demand_reason_code';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
- $sql.= " WHERE c.entity IN (".getEntity('commande').")";
- if ($id) $sql.= " AND c.rowid=".$id;
- if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
- if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
- if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $result = $this->db->query($sql);
+ if ($id) $sql.= " WHERE c.rowid=".$id;
+ else $sql.= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid
+
+ if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
+ if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
+ if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
+
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ $result = $this->db->query($sql);
if ($result)
{
$obj = $this->db->fetch_object($result);
@@ -1607,50 +1645,50 @@ class Commande extends CommonOrder
$this->id = $obj->rowid;
$this->entity = $obj->entity;
- $this->ref = $obj->ref;
- $this->ref_client = $obj->ref_client;
- $this->ref_customer = $obj->ref_client;
- $this->ref_ext = $obj->ref_ext;
- $this->ref_int = $obj->ref_int;
- $this->socid = $obj->fk_soc;
- $this->statut = $obj->fk_statut;
- $this->user_author_id = $obj->fk_user_author;
- $this->user_valid = $obj->fk_user_valid;
- $this->total_ht = $obj->total_ht;
- $this->total_tva = $obj->total_tva;
- $this->total_localtax1 = $obj->total_localtax1;
- $this->total_localtax2 = $obj->total_localtax2;
- $this->total_ttc = $obj->total_ttc;
- $this->date = $this->db->jdate($obj->date_commande);
- $this->date_commande = $this->db->jdate($obj->date_commande);
- $this->remise = $obj->remise;
- $this->remise_percent = $obj->remise_percent;
- $this->remise_absolue = $obj->remise_absolue;
- $this->source = $obj->source;
- $this->billed = $obj->billed;
- $this->note = $obj->note_private; // deprecated
- $this->note_private = $obj->note_private;
- $this->note_public = $obj->note_public;
- $this->fk_project = $obj->fk_projet;
- $this->modelpdf = $obj->model_pdf;
- $this->last_main_doc = $obj->last_main_doc;
- $this->mode_reglement_id = $obj->fk_mode_reglement;
- $this->mode_reglement_code = $obj->mode_reglement_code;
- $this->mode_reglement = $obj->mode_reglement_libelle;
- $this->cond_reglement_id = $obj->fk_cond_reglement;
- $this->cond_reglement_code = $obj->cond_reglement_code;
- $this->cond_reglement = $obj->cond_reglement_libelle;
- $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
- $this->fk_account = $obj->fk_account;
- $this->availability_id = $obj->fk_availability;
- $this->availability_code = $obj->availability_code;
- $this->availability = $obj->availability_label;
- $this->demand_reason_id = $obj->fk_input_reason;
- $this->demand_reason_code = $obj->demand_reason_code;
- $this->date_livraison = $this->db->jdate($obj->date_livraison);
- $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
- $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null;
- $this->fk_delivery_address = $obj->fk_delivery_address;
+ $this->ref = $obj->ref;
+ $this->ref_client = $obj->ref_client;
+ $this->ref_customer = $obj->ref_client;
+ $this->ref_ext = $obj->ref_ext;
+ $this->ref_int = $obj->ref_int;
+ $this->socid = $obj->fk_soc;
+ $this->statut = $obj->fk_statut;
+ $this->user_author_id = $obj->fk_user_author;
+ $this->user_valid = $obj->fk_user_valid;
+ $this->total_ht = $obj->total_ht;
+ $this->total_tva = $obj->total_tva;
+ $this->total_localtax1 = $obj->total_localtax1;
+ $this->total_localtax2 = $obj->total_localtax2;
+ $this->total_ttc = $obj->total_ttc;
+ $this->date = $this->db->jdate($obj->date_commande);
+ $this->date_commande = $this->db->jdate($obj->date_commande);
+ $this->remise = $obj->remise;
+ $this->remise_percent = $obj->remise_percent;
+ $this->remise_absolue = $obj->remise_absolue;
+ $this->source = $obj->source;
+ $this->billed = $obj->billed;
+ $this->note = $obj->note_private; // deprecated
+ $this->note_private = $obj->note_private;
+ $this->note_public = $obj->note_public;
+ $this->fk_project = $obj->fk_projet;
+ $this->modelpdf = $obj->model_pdf;
+ $this->last_main_doc = $obj->last_main_doc;
+ $this->mode_reglement_id = $obj->fk_mode_reglement;
+ $this->mode_reglement_code = $obj->mode_reglement_code;
+ $this->mode_reglement = $obj->mode_reglement_libelle;
+ $this->cond_reglement_id = $obj->fk_cond_reglement;
+ $this->cond_reglement_code = $obj->cond_reglement_code;
+ $this->cond_reglement = $obj->cond_reglement_libelle;
+ $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
+ $this->fk_account = $obj->fk_account;
+ $this->availability_id = $obj->fk_availability;
+ $this->availability_code = $obj->availability_code;
+ $this->availability = $obj->availability_label;
+ $this->demand_reason_id = $obj->fk_input_reason;
+ $this->demand_reason_code = $obj->demand_reason_code;
+ $this->date_livraison = $this->db->jdate($obj->date_livraison);
+ $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
+ $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null;
+ $this->fk_delivery_address = $obj->fk_delivery_address;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
@@ -1665,207 +1703,211 @@ class Commande extends CommonOrder
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
- $this->extraparams = (array) json_decode($obj->extraparams, true);
+ $this->extraparams = (array) json_decode($obj->extraparams, true);
- $this->lines = array();
+ $this->lines = array();
- if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
+ if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
- // Retreive all extrafield
- // fetch optionals attributes and labels
- $this->fetch_optionals();
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
- $this->db->free($result);
+ $this->db->free($result);
- /*
- * Lines
- */
- $result=$this->fetch_lines();
- if ($result < 0)
- {
- return -3;
- }
- return 1;
- }
- else
- {
- $this->error='Order with id '.$id.' not found sql='.$sql;
- return 0;
- }
- }
- else
- {
- $this->error=$this->db->error();
- return -1;
- }
- }
+ /*
+ * Lines
+ */
+ $result=$this->fetch_lines();
+ if ($result < 0)
+ {
+ return -3;
+ }
+ return 1;
+ }
+ else
+ {
+ $this->error='Order with id '.$id.' not found sql='.$sql;
+ return 0;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
- /**
- * Adding line of fixed discount in the order in DB
- *
- * @param int $idremise Id de la remise fixe
- * @return int >0 si ok, <0 si ko
- */
- function insert_discount($idremise)
- {
- global $langs;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Adding line of fixed discount in the order in DB
+ *
+ * @param int $idremise Id de la remise fixe
+ * @return int >0 si ok, <0 si ko
+ */
+ function insert_discount($idremise)
+ {
+ // phpcs:enable
+ global $langs;
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
- $this->db->begin();
+ $this->db->begin();
- $remise=new DiscountAbsolute($this->db);
- $result=$remise->fetch($idremise);
+ $remise=new DiscountAbsolute($this->db);
+ $result=$remise->fetch($idremise);
- if ($result > 0)
- {
- if ($remise->fk_facture) // Protection against multiple submission
- {
- $this->error=$langs->trans("ErrorDiscountAlreadyUsed");
- $this->db->rollback();
- return -5;
- }
+ if ($result > 0)
+ {
+ if ($remise->fk_facture) // Protection against multiple submission
+ {
+ $this->error=$langs->trans("ErrorDiscountAlreadyUsed");
+ $this->db->rollback();
+ return -5;
+ }
- $line = new OrderLine($this->db);
+ $line = new OrderLine($this->db);
- $line->fk_commande=$this->id;
- $line->fk_remise_except=$remise->id;
- $line->desc=$remise->description; // Description ligne
- $line->vat_src_code=$remise->vat_src_code;
- $line->tva_tx=$remise->tva_tx;
- $line->subprice=-$remise->amount_ht;
- $line->price=-$remise->amount_ht;
- $line->fk_product=0; // Id produit predefini
- $line->qty=1;
- $line->remise=0;
- $line->remise_percent=0;
- $line->rang=-1;
- $line->info_bits=2;
+ $line->fk_commande=$this->id;
+ $line->fk_remise_except=$remise->id;
+ $line->desc=$remise->description; // Description ligne
+ $line->vat_src_code=$remise->vat_src_code;
+ $line->tva_tx=$remise->tva_tx;
+ $line->subprice=-$remise->amount_ht;
+ $line->price=-$remise->amount_ht;
+ $line->fk_product=0; // Id produit predefini
+ $line->qty=1;
+ $line->remise=0;
+ $line->remise_percent=0;
+ $line->rang=-1;
+ $line->info_bits=2;
- $line->total_ht = -$remise->amount_ht;
- $line->total_tva = -$remise->amount_tva;
- $line->total_ttc = -$remise->amount_ttc;
+ $line->total_ht = -$remise->amount_ht;
+ $line->total_tva = -$remise->amount_tva;
+ $line->total_ttc = -$remise->amount_ttc;
- $result=$line->insert();
- if ($result > 0)
- {
- $result=$this->update_price(1);
- if ($result > 0)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$line->error;
- $this->db->rollback();
- return -2;
- }
- }
- else
- {
- $this->db->rollback();
- return -2;
- }
- }
+ $result=$line->insert();
+ if ($result > 0)
+ {
+ $result=$this->update_price(1);
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$line->error;
+ $this->db->rollback();
+ return -2;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ return -2;
+ }
+ }
- /**
- * Load array lines
- *
- * @param int $only_product Return only physical products
- * @return int <0 if KO, >0 if OK
- */
- function fetch_lines($only_product=0)
- {
- $this->lines=array();
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Load array lines
+ *
+ * @param int $only_product Return only physical products
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch_lines($only_product=0)
+ {
+ // phpcs:enable
+ $this->lines=array();
- $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,';
- $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
- $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
- $sql.= ' l.fk_unit,';
+ $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,';
+ $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
+ $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
+ $sql.= ' l.fk_unit,';
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
- $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch,';
- $sql.= ' p.weight, p.weight_units, p.volume, p.volume_units';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
- $sql.= ' WHERE l.fk_commande = '.$this->id;
- if ($only_product) $sql .= ' AND p.fk_product_type = 0';
- $sql .= ' ORDER BY l.rang, l.rowid';
+ $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch,';
+ $sql.= ' p.weight, p.weight_units, p.volume, p.volume_units';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
+ $sql.= ' WHERE l.fk_commande = '.$this->id;
+ if ($only_product) $sql .= ' AND p.fk_product_type = 0';
+ $sql .= ' ORDER BY l.rang, l.rowid';
- dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
- {
- $num = $this->db->num_rows($result);
+ dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $num = $this->db->num_rows($result);
- $i = 0;
- while ($i < $num)
- {
- $objp = $this->db->fetch_object($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $objp = $this->db->fetch_object($result);
- $line = new OrderLine($this->db);
+ $line = new OrderLine($this->db);
- $line->rowid = $objp->rowid;
- $line->id = $objp->rowid;
- $line->fk_commande = $objp->fk_commande;
- $line->commande_id = $objp->fk_commande;
- $line->label = $objp->custom_label;
- $line->desc = $objp->description;
- $line->description = $objp->description; // Description line
- $line->product_type = $objp->product_type;
- $line->qty = $objp->qty;
+ $line->rowid = $objp->rowid;
+ $line->id = $objp->rowid;
+ $line->fk_commande = $objp->fk_commande;
+ $line->commande_id = $objp->fk_commande;
+ $line->label = $objp->custom_label;
+ $line->desc = $objp->description;
+ $line->description = $objp->description; // Description line
+ $line->product_type = $objp->product_type;
+ $line->qty = $objp->qty;
- $line->vat_src_code = $objp->vat_src_code;
- $line->tva_tx = $objp->tva_tx;
- $line->localtax1_tx = $objp->localtax1_tx;
- $line->localtax2_tx = $objp->localtax2_tx;
- $line->localtax1_type = $objp->localtax1_type;
- $line->localtax2_type = $objp->localtax2_type;
- $line->total_ht = $objp->total_ht;
- $line->total_ttc = $objp->total_ttc;
- $line->total_tva = $objp->total_tva;
- $line->total_localtax1 = $objp->total_localtax1;
- $line->total_localtax2 = $objp->total_localtax2;
- $line->subprice = $objp->subprice;
- $line->fk_remise_except = $objp->fk_remise_except;
- $line->remise_percent = $objp->remise_percent;
- $line->price = $objp->price;
- $line->fk_product = $objp->fk_product;
+ $line->vat_src_code = $objp->vat_src_code;
+ $line->tva_tx = $objp->tva_tx;
+ $line->localtax1_tx = $objp->localtax1_tx;
+ $line->localtax2_tx = $objp->localtax2_tx;
+ $line->localtax1_type = $objp->localtax1_type;
+ $line->localtax2_type = $objp->localtax2_type;
+ $line->total_ht = $objp->total_ht;
+ $line->total_ttc = $objp->total_ttc;
+ $line->total_tva = $objp->total_tva;
+ $line->total_localtax1 = $objp->total_localtax1;
+ $line->total_localtax2 = $objp->total_localtax2;
+ $line->subprice = $objp->subprice;
+ $line->fk_remise_except = $objp->fk_remise_except;
+ $line->remise_percent = $objp->remise_percent;
+ $line->price = $objp->price;
+ $line->fk_product = $objp->fk_product;
$line->fk_fournprice = $objp->fk_fournprice;
- $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
- $line->pa_ht = $marginInfos[0];
- $line->marge_tx = $marginInfos[1];
- $line->marque_tx = $marginInfos[2];
- $line->rang = $objp->rang;
- $line->info_bits = $objp->info_bits;
- $line->special_code = $objp->special_code;
- $line->fk_parent_line = $objp->fk_parent_line;
+ $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
+ $line->pa_ht = $marginInfos[0];
+ $line->marge_tx = $marginInfos[1];
+ $line->marque_tx = $marginInfos[2];
+ $line->rang = $objp->rang;
+ $line->info_bits = $objp->info_bits;
+ $line->special_code = $objp->special_code;
+ $line->fk_parent_line = $objp->fk_parent_line;
- $line->ref = $objp->product_ref;
- $line->product_ref = $objp->product_ref;
- $line->libelle = $objp->product_label;
- $line->product_label = $objp->product_label;
- $line->product_desc = $objp->product_desc;
- $line->product_tobatch = $objp->product_tobatch;
- $line->fk_product_type = $objp->fk_product_type; // Produit ou service
- $line->fk_unit = $objp->fk_unit;
+ $line->ref = $objp->product_ref;
+ $line->product_ref = $objp->product_ref;
+ $line->libelle = $objp->product_label;
+ $line->product_label = $objp->product_label;
+ $line->product_desc = $objp->product_desc;
+ $line->product_tobatch = $objp->product_tobatch;
+ $line->fk_product_type = $objp->fk_product_type; // Produit ou service
+ $line->fk_unit = $objp->fk_unit;
- $line->weight = $objp->weight;
- $line->weight_units = $objp->weight_units;
- $line->volume = $objp->volume;
- $line->volume_units = $objp->volume_units;
+ $line->weight = $objp->weight;
+ $line->weight_units = $objp->weight_units;
+ $line->volume = $objp->volume;
+ $line->volume_units = $objp->volume_units;
- $line->date_start = $this->db->jdate($objp->date_start);
- $line->date_end = $this->db->jdate($objp->date_end);
+ $line->date_start = $this->db->jdate($objp->date_start);
+ $line->date_end = $this->db->jdate($objp->date_end);
// Multicurrency
$line->fk_multicurrency = $objp->fk_multicurrency;
@@ -1875,810 +1917,828 @@ class Commande extends CommonOrder
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
- $this->lines[$i] = $line;
+ $this->lines[$i] = $line;
- $i++;
- }
+ $i++;
+ }
- $this->db->free($result);
+ $this->db->free($result);
- return 1;
- }
- else
- {
- $this->error=$this->db->error();
- return -3;
- }
- }
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -3;
+ }
+ }
- /**
- * Return number of line with type product.
- *
- * @return int <0 if KO, Nbr of product lines if OK
- */
- function getNbOfProductsLines()
- {
- $nb=0;
- foreach($this->lines as $line)
- {
- if ($line->product_type == 0) $nb++;
- }
- return $nb;
- }
+ /**
+ * Return number of line with type product.
+ *
+ * @return int <0 if KO, Nbr of product lines if OK
+ */
+ function getNbOfProductsLines()
+ {
+ $nb=0;
+ foreach($this->lines as $line)
+ {
+ if ($line->product_type == 0) $nb++;
+ }
+ return $nb;
+ }
- /**
- * Return number of line with type service.
- *
- * @return int <0 if KO, Nbr of service lines if OK
- */
- function getNbOfServicesLines()
- {
- $nb=0;
- foreach($this->lines as $line)
- {
- if ($line->product_type == 1) $nb++;
- }
- return $nb;
- }
+ /**
+ * Return number of line with type service.
+ *
+ * @return int <0 if KO, Nbr of service lines if OK
+ */
+ function getNbOfServicesLines()
+ {
+ $nb=0;
+ foreach($this->lines as $line)
+ {
+ if ($line->product_type == 1) $nb++;
+ }
+ return $nb;
+ }
- /**
- * Count numbe rof shipments for this order
- *
- * @return int <0 if KO, Nb of shipment found if OK
- */
- function getNbOfShipments()
- {
- $nb = 0;
+ /**
+ * Count numbe rof shipments for this order
+ *
+ * @return int <0 if KO, Nb of shipment found if OK
+ */
+ function getNbOfShipments()
+ {
+ $nb = 0;
- $sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
- $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' WHERE';
- $sql.= ' ed.fk_origin_line = cd.rowid';
- $sql.= ' AND cd.fk_commande =' .$this->id;
- //print $sql;
+ $sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
+ $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
+ $sql.= ' WHERE';
+ $sql.= ' ed.fk_origin_line = cd.rowid';
+ $sql.= ' AND cd.fk_commande =' .$this->id;
+ //print $sql;
- dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $obj = $this->db->fetch_object($resql);
- if ($obj) $nb = $obj->nb;
+ dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj) $nb = $obj->nb;
- $this->db->free($resql);
- return $nb;
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
+ $this->db->free($resql);
+ return $nb;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Load array this->expeditions of lines of shipments with nb of products sent for each order line
- * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
- *
- * @param int $filtre_statut Filter on shipment status
- * @return int <0 if KO, Nb of lines found if OK
- */
- function loadExpeditions($filtre_statut=-1)
- {
- $this->expeditions = array();
+ /**
+ * Load array this->expeditions of lines of shipments with nb of products sent for each order line
+ * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
+ *
+ * @param int $filtre_statut Filter on shipment status
+ * @return int <0 if KO, Nb of lines found if OK
+ */
+ function loadExpeditions($filtre_statut=-1)
+ {
+ $this->expeditions = array();
- $sql = 'SELECT cd.rowid, cd.fk_product,';
- $sql.= ' sum(ed.qty) as qty';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
- if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,';
- $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' WHERE';
- if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND';
- $sql.= ' ed.fk_origin_line = cd.rowid';
- $sql.= ' AND cd.fk_commande =' .$this->id;
- if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
- if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
- $sql.= ' GROUP BY cd.rowid, cd.fk_product';
- //print $sql;
+ $sql = 'SELECT cd.rowid, cd.fk_product,';
+ $sql.= ' sum(ed.qty) as qty';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
+ if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,';
+ $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
+ $sql.= ' WHERE';
+ if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND';
+ $sql.= ' ed.fk_origin_line = cd.rowid';
+ $sql.= ' AND cd.fk_commande =' .$this->id;
+ if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
+ if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
+ $sql.= ' GROUP BY cd.rowid, cd.fk_product';
+ //print $sql;
- dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- $this->expeditions[$obj->rowid] = $obj->qty;
- $i++;
- }
- $this->db->free($resql);
- return $num;
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $this->expeditions[$obj->rowid] = $obj->qty;
+ $i++;
+ }
+ $this->db->free($resql);
+ return $num;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Returns a array with expeditions lines number
- *
- * @return int Nb of shipments
- *
- * TODO deprecate, move to Shipping class
- */
- function nb_expedition()
- {
- $sql = 'SELECT count(*)';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
- $sql.= ', '.MAIN_DB_PREFIX.'element_element as el';
- $sql.= ' WHERE el.fk_source = '.$this->id;
- $sql.= " AND el.fk_target = e.rowid";
- $sql.= " AND el.targettype = 'shipping'";
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Returns a array with expeditions lines number
+ *
+ * @return int Nb of shipments
+ *
+ * TODO deprecate, move to Shipping class
+ */
+ function nb_expedition()
+ {
+ // phpcs:enable
+ $sql = 'SELECT count(*)';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
+ $sql.= ', '.MAIN_DB_PREFIX.'element_element as el';
+ $sql.= ' WHERE el.fk_source = '.$this->id;
+ $sql.= " AND el.fk_target = e.rowid";
+ $sql.= " AND el.targettype = 'shipping'";
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $row = $this->db->fetch_row($resql);
- return $row[0];
- }
- else dol_print_error($this->db);
- }
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $row = $this->db->fetch_row($resql);
+ return $row[0];
+ }
+ else dol_print_error($this->db);
+ }
- /**
- * Return a array with the pending stock by product
- *
- * @param int $filtre_statut Filtre sur statut
- * @return int 0 si OK, <0 si KO
- *
- * TODO FONCTION NON FINIE A FINIR
- */
- function stock_array($filtre_statut=self::STATUS_CANCELED)
- {
- $this->stocks = array();
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Return a array with the pending stock by product
+ *
+ * @param int $filtre_statut Filtre sur statut
+ * @return int 0 si OK, <0 si KO
+ *
+ * TODO FONCTION NON FINIE A FINIR
+ */
+ function stock_array($filtre_statut=self::STATUS_CANCELED)
+ {
+ // phpcs:enable
+ $this->stocks = array();
- // Tableau des id de produit de la commande
+ // Tableau des id de produit de la commande
$array_of_product=array();
- // Recherche total en stock pour chaque produit
- // TODO $array_of_product est défini vide juste au dessus !!
- if (count($array_of_product))
- {
- $sql = "SELECT fk_product, sum(ps.reel) as total";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
- $sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")";
- $sql.= ' GROUP BY fk_product ';
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- $this->stocks[$obj->fk_product] = $obj->total;
- $i++;
- }
- $this->db->free($resql);
- }
- }
- return 0;
- }
+ // Recherche total en stock pour chaque produit
+ // TODO $array_of_product est défini vide juste au dessus !!
+ if (count($array_of_product))
+ {
+ $sql = "SELECT fk_product, sum(ps.reel) as total";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
+ $sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")";
+ $sql.= ' GROUP BY fk_product ';
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $this->stocks[$obj->fk_product] = $obj->total;
+ $i++;
+ }
+ $this->db->free($resql);
+ }
+ }
+ return 0;
+ }
- /**
- * Delete an order line
- *
- * @param User $user User object
- * @param int $lineid Id of line to delete
- * @return int >0 if OK, 0 if nothing to do, <0 if KO
- */
- function deleteline($user=null, $lineid=0)
- {
- if ($this->statut == self::STATUS_DRAFT)
- {
- $this->db->begin();
+ /**
+ * Delete an order line
+ *
+ * @param User $user User object
+ * @param int $lineid Id of line to delete
+ * @return int >0 if OK, 0 if nothing to do, <0 if KO
+ */
+ function deleteline($user=null, $lineid=0)
+ {
+ if ($this->statut == self::STATUS_DRAFT)
+ {
+ $this->db->begin();
- $sql = "SELECT fk_product, qty";
- $sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
- $sql.= " WHERE rowid = ".$lineid;
+ $sql = "SELECT fk_product, qty";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
+ $sql.= " WHERE rowid = ".$lineid;
- $result = $this->db->query($sql);
- if ($result)
- {
- $obj = $this->db->fetch_object($result);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $obj = $this->db->fetch_object($result);
- if ($obj)
- {
- $product = new Product($this->db);
- $product->id = $obj->fk_product;
+ if ($obj)
+ {
+ $product = new Product($this->db);
+ $product->id = $obj->fk_product;
- // Delete line
- $line = new OrderLine($this->db);
+ // Delete line
+ $line = new OrderLine($this->db);
- // For triggers
- $line->fetch($lineid);
+ // For triggers
+ $line->fetch($lineid);
- if ($line->delete($user) > 0)
- {
- $result=$this->update_price(1);
-
- if ($result > 0)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
- else
- {
- $this->db->rollback();
- $this->error=$line->error;
- return -1;
- }
- }
- else
- {
- $this->db->rollback();
- return 0;
- }
- }
- else
- {
- $this->db->rollback();
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
- else
- {
- $this->error='ErrorDeleteLineNotAllowedByObjectStatus';
- return -1;
- }
- }
-
- /**
- * Applique une remise relative
- *
- * @param User $user User qui positionne la remise
- * @param float $remise Discount (percent)
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_remise($user, $remise, $notrigger=0)
- {
- $remise=trim($remise)?trim($remise):0;
-
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $remise=price2num($remise);
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET remise_percent = '.$remise;
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->remise_percent = $remise;
- $this->update_price(1);
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- }
-
-
- /**
- * Applique une remise absolue
- *
- * @param User $user User qui positionne la remise
- * @param float $remise Discount
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_remise_absolue($user, $remise, $notrigger=0)
- {
- $remise=trim($remise)?trim($remise):0;
-
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $remise=price2num($remise);
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET remise_absolue = '.$remise;
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->remise_absolue = $remise;
- $this->update_price(1);
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- }
-
-
- /**
- * Set the order date
- *
- * @param User $user Object user making change
- * @param int $date Date
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_date($user, $date, $notrigger=0)
- {
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null');
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->date = $date;
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- return -2;
- }
- }
-
- /**
- * Set the planned delivery date
- *
- * @param User $user Objet utilisateur qui modifie
- * @param int $date_livraison Date de livraison
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 si ko, >0 si ok
- */
- function set_date_livraison($user, $date_livraison, $notrigger=0)
- {
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
- $sql.= " WHERE rowid = ".$this->id;
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->date_livraison = $date_livraison;
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- return -2;
- }
- }
-
- /**
- * Return list of orders (eventuelly filtered on a user) into an array
- *
- * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name)
- * @param int $draft 0=not draft, 1=draft
- * @param User $excluser Objet user to exclude
- * @param int $socid Id third pary
- * @param int $limit For pagination
- * @param int $offset For pagination
- * @param string $sortfield Sort criteria
- * @param string $sortorder Sort order
- * @return int -1 if KO, array with result if OK
- */
- function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC')
- {
- global $user;
-
- $ga = array();
-
- $sql = "SELECT s.rowid, s.nom as name, s.client,";
- $sql.= " c.rowid as cid, c.ref";
- if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
- if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.entity IN (".getEntity('commande').")";
- $sql.= " AND c.fk_soc = s.rowid";
- if (! $user->rights->societe->client->voir && ! $socid) //restriction
- {
- $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
- }
- if ($socid) $sql.= " AND s.rowid = ".$socid;
- if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT;
- if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id;
- $sql.= $this->db->order($sortfield,$sortorder);
- $sql.= $this->db->plimit($limit,$offset);
-
- $result=$this->db->query($sql);
- if ($result)
- {
- $numc = $this->db->num_rows($result);
- if ($numc)
- {
- $i = 0;
- while ($i < $numc)
- {
- $obj = $this->db->fetch_object($result);
-
- if ($shortlist == 1)
- {
- $ga[$obj->cid] = $obj->ref;
- }
- else if ($shortlist == 2)
- {
- $ga[$obj->cid] = $obj->ref.' ('.$obj->name.')';
- }
- else
+ if ($line->delete($user) > 0)
{
- $ga[$i]['id'] = $obj->cid;
- $ga[$i]['ref'] = $obj->ref;
- $ga[$i]['name'] = $obj->name;
- }
- $i++;
- }
- }
- return $ga;
- }
- else
- {
- dol_print_error($this->db);
- return -1;
- }
- }
+ $result=$this->update_price(1);
- /**
- * Update delivery delay
- *
- * @param int $availability_id Id du nouveau mode
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int >0 if OK, <0 if KO
- */
- function availability($availability_id, $notrigger=0)
- {
- global $user;
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$line->error;
+ return -1;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error='ErrorDeleteLineNotAllowedByObjectStatus';
+ return -1;
+ }
+ }
- dol_syslog('Commande::availability('.$availability_id.')');
- if ($this->statut >= self::STATUS_DRAFT)
- {
- $error=0;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Applique une remise relative
+ *
+ * @param User $user User qui positionne la remise
+ * @param float $remise Discount (percent)
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_remise($user, $remise, $notrigger=0)
+ {
+ // phpcs:enable
+ $remise=trim($remise)?trim($remise):0;
- $this->db->begin();
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql .= ' SET fk_availability = '.$availability_id;
- $sql .= ' WHERE rowid='.$this->id;
+ $this->db->begin();
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
+ $remise=price2num($remise);
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->availability_id = $availability_id;
- }
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET remise_percent = '.$remise;
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- $error_str='Command status do not meet requirement '.$this->statut;
- dol_syslog(__METHOD__.$error_str, LOG_ERR);
- $this->error=$error_str;
- $this->errors[]= $this->error;
- return -2;
- }
- }
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->remise_percent = $remise;
+ $this->update_price(1);
+ }
- /**
- * Update order demand_reason
- *
- * @param int $demand_reason_id Id of new demand
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int >0 if ok, <0 if ko
- */
- function demand_reason($demand_reason_id, $notrigger=0)
- {
- global $user;
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
- if ($this->statut >= self::STATUS_DRAFT)
- {
- $error=0;
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ }
- $this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql .= ' SET fk_input_reason = '.$demand_reason_id;
- $sql .= ' WHERE rowid='.$this->id;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Applique une remise absolue
+ *
+ * @param User $user User qui positionne la remise
+ * @param float $remise Discount
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_remise_absolue($user, $remise, $notrigger=0)
+ {
+ // phpcs:enable
+ $remise=trim($remise)?trim($remise):0;
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->demand_reason_id = $demand_reason_id;
- }
+ $this->db->begin();
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ $remise=price2num($remise);
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- $error_str='order status do not meet requirement '.$this->statut;
- dol_syslog(__METHOD__.$error_str, LOG_ERR);
- $this->error=$error_str;
- $this->errors[]= $this->error;
- return -2;
- }
- }
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET remise_absolue = '.$remise;
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
- /**
- * Set customer ref
- *
- * @param User $user User that make change
- * @param string $ref_client Customer ref
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_ref_client($user, $ref_client, $notrigger=0)
- {
- if ($user->rights->commande->creer)
- {
- $error=0;
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
- $this->db->begin();
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->remise_absolue = $remise;
+ $this->update_price(1);
+ }
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET';
- $sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
- $sql.= ' WHERE rowid = '.$this->id;
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ }
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->ref_client = $ref_client;
- }
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- return -1;
- }
- }
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set the order date
+ *
+ * @param User $user Object user making change
+ * @param int $date Date
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_date($user, $date, $notrigger=0)
+ {
+ // phpcs:enable
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null');
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->date = $date;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set the planned delivery date
+ *
+ * @param User $user Objet utilisateur qui modifie
+ * @param int $date_livraison Date de livraison
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 si ko, >0 si ok
+ */
+ function set_date_livraison($user, $date_livraison, $notrigger=0)
+ {
+ // phpcs:enable
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->date_livraison = $date_livraison;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Return list of orders (eventuelly filtered on a user) into an array
+ *
+ * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name)
+ * @param int $draft 0=not draft, 1=draft
+ * @param User $excluser Objet user to exclude
+ * @param int $socid Id third pary
+ * @param int $limit For pagination
+ * @param int $offset For pagination
+ * @param string $sortfield Sort criteria
+ * @param string $sortorder Sort order
+ * @return int -1 if KO, array with result if OK
+ */
+ function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC')
+ {
+ // phpcs:enable
+ global $user;
+
+ $ga = array();
+
+ $sql = "SELECT s.rowid, s.nom as name, s.client,";
+ $sql.= " c.rowid as cid, c.ref";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE c.entity IN (".getEntity('commande').")";
+ $sql.= " AND c.fk_soc = s.rowid";
+ if (! $user->rights->societe->client->voir && ! $socid) //restriction
+ {
+ $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ }
+ if ($socid) $sql.= " AND s.rowid = ".$socid;
+ if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT;
+ if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id;
+ $sql.= $this->db->order($sortfield,$sortorder);
+ $sql.= $this->db->plimit($limit,$offset);
+
+ $result=$this->db->query($sql);
+ if ($result)
+ {
+ $numc = $this->db->num_rows($result);
+ if ($numc)
+ {
+ $i = 0;
+ while ($i < $numc)
+ {
+ $obj = $this->db->fetch_object($result);
+
+ if ($shortlist == 1)
+ {
+ $ga[$obj->cid] = $obj->ref;
+ }
+ else if ($shortlist == 2)
+ {
+ $ga[$obj->cid] = $obj->ref.' ('.$obj->name.')';
+ }
+ else
+ {
+ $ga[$i]['id'] = $obj->cid;
+ $ga[$i]['ref'] = $obj->ref;
+ $ga[$i]['name'] = $obj->name;
+ }
+ $i++;
+ }
+ }
+ return $ga;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
+ /**
+ * Update delivery delay
+ *
+ * @param int $availability_id Id du nouveau mode
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int >0 if OK, <0 if KO
+ */
+ function availability($availability_id, $notrigger=0)
+ {
+ global $user;
+
+ dol_syslog('Commande::availability('.$availability_id.')');
+ if ($this->statut >= self::STATUS_DRAFT)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql .= ' SET fk_availability = '.$availability_id;
+ $sql .= ' WHERE rowid='.$this->id;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->availability_id = $availability_id;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ $error_str='Command status do not meet requirement '.$this->statut;
+ dol_syslog(__METHOD__.$error_str, LOG_ERR);
+ $this->error=$error_str;
+ $this->errors[]= $this->error;
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Update order demand_reason
+ *
+ * @param int $demand_reason_id Id of new demand
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int >0 if ok, <0 if ko
+ */
+ function demand_reason($demand_reason_id, $notrigger=0)
+ {
+ // phpcs:enable
+ global $user;
+
+ dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
+ if ($this->statut >= self::STATUS_DRAFT)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql .= ' SET fk_input_reason = '.$demand_reason_id;
+ $sql .= ' WHERE rowid='.$this->id;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->demand_reason_id = $demand_reason_id;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ $error_str='order status do not meet requirement '.$this->statut;
+ dol_syslog(__METHOD__.$error_str, LOG_ERR);
+ $this->error=$error_str;
+ $this->errors[]= $this->error;
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set customer ref
+ *
+ * @param User $user User that make change
+ * @param string $ref_client Customer ref
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_ref_client($user, $ref_client, $notrigger=0)
+ {
+ // phpcs:enable
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET';
+ $sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
+ $sql.= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->ref_client = $ref_client;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ return -1;
+ }
+ }
/**
* Classify the order as invoiced
@@ -2689,7 +2749,7 @@ class Commande extends CommonOrder
*/
function classifyBilled(User $user, $notrigger=0)
{
- $error = 0;
+ $error = 0;
$this->db->begin();
@@ -2708,10 +2768,10 @@ class Commande extends CommonOrder
if (! $notrigger && empty($error))
{
- // Call trigger
- $result=$this->call_trigger('ORDER_CLASSIFY_BILLED',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CLASSIFY_BILLED',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
if (! $error)
@@ -2733,7 +2793,7 @@ class Commande extends CommonOrder
else
{
$this->error=$this->db->error();
- $this->db->rollback();
+ $this->db->rollback();
return -1;
}
}
@@ -2745,146 +2805,146 @@ class Commande extends CommonOrder
*/
function classifyUnBilled()
{
- global $conf, $user, $langs;
- $error = 0;
+ global $conf, $user, $langs;
+ $error = 0;
- $this->db->begin();
+ $this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0';
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0';
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
- dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->billed=1;
- }
+ dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->billed=1;
+ }
- // Call trigger
- $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
+ if ($result < 0) $error++;
+ // End call triggers
- if (! $error)
- {
- $this->billed=0;
+ if (! $error)
+ {
+ $this->billed=0;
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -1;
- }
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
}
- /**
- * Update a line in database
- *
- * @param int $rowid Id of line to update
- * @param string $desc Description of line
- * @param float $pu Unit price
- * @param float $qty Quantity
- * @param float $remise_percent Percent of discount
- * @param float $txtva Taux TVA
- * @param float $txlocaltax1 Local tax 1 rate
- * @param float $txlocaltax2 Local tax 2 rate
- * @param string $price_base_type HT or TTC
- * @param int $info_bits Miscellaneous informations on line
- * @param int $date_start Start date of the line
- * @param int $date_end End date of the line
- * @param int $type Type of line (0=product, 1=service)
- * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
- * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules)
- * @param int $fk_fournprice Id of origin supplier price
- * @param int $pa_ht Price (without tax) of product when it was bought
- * @param string $label Label
- * @param int $special_code Special code (also used by externals modules!)
+ /**
+ * Update a line in database
+ *
+ * @param int $rowid Id of line to update
+ * @param string $desc Description of line
+ * @param float $pu Unit price
+ * @param float $qty Quantity
+ * @param float $remise_percent Percent of discount
+ * @param float $txtva Taux TVA
+ * @param float $txlocaltax1 Local tax 1 rate
+ * @param float $txlocaltax2 Local tax 2 rate
+ * @param string $price_base_type HT or TTC
+ * @param int $info_bits Miscellaneous informations on line
+ * @param int $date_start Start date of the line
+ * @param int $date_end End date of the line
+ * @param int $type Type of line (0=product, 1=service)
+ * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
+ * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules)
+ * @param int $fk_fournprice Id of origin supplier price
+ * @param int $pa_ht Price (without tax) of product when it was bought
+ * @param string $label Label
+ * @param int $special_code Special code (also used by externals modules!)
* @param array $array_options extrafields array
- * @param string $fk_unit Code of the unit to use. Null to use the default one
+ * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Amount in currency
- * @param int $notrigger disable line update trigger
- * @return int < 0 if KO, > 0 if OK
- */
+ * @param int $notrigger disable line update trigger
+ * @return int < 0 if KO, > 0 if OK
+ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0, $notrigger=0)
- {
- global $conf, $mysoc, $langs, $user;
+ {
+ global $conf, $mysoc, $langs, $user;
- dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- if (! empty($this->brouillon))
- {
- $this->db->begin();
+ if (! empty($this->brouillon))
+ {
+ $this->db->begin();
- // Clean parameters
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($special_code) || $special_code == 3) $special_code=0;
+ // Clean parameters
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($txtva)) $txtva=0;
+ if (empty($txlocaltax1)) $txlocaltax1=0;
+ if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($special_code) || $special_code == 3) $special_code=0;
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu = price2num($pu);
- $pa_ht=price2num($pa_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $txtva=price2num($txtva);
- $txlocaltax1=price2num($txlocaltax1);
- $txlocaltax2=price2num($txlocaltax2);
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu = price2num($pu);
+ $pa_ht=price2num($pa_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $txtva=price2num($txtva);
+ $txlocaltax1=price2num($txlocaltax1);
+ $txlocaltax2=price2num($txlocaltax2);
- // Calcul du total TTC et de la TVA pour la ligne a partir de
- // qty, pu, remise_percent et txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // Calcul du total TTC et de la TVA pour la ligne a partir de
+ // qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+ $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
- // Clean vat code
- $vat_src_code='';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
- $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
- // Anciens indicateurs: $price, $subprice (a ne plus utiliser)
- $price = $pu_ht;
+ // Anciens indicateurs: $price, $subprice (a ne plus utiliser)
+ $price = $pu_ht;
if ($price_base_type == 'TTC')
{
$subprice = $pu_ttc;
@@ -2893,72 +2953,72 @@ class Commande extends CommonOrder
{
$subprice = $pu_ht;
}
- $remise = 0;
- if ($remise_percent > 0)
- {
- $remise = round(($pu * $remise_percent / 100),2);
- $price = ($pu - $remise);
- }
+ $remise = 0;
+ if ($remise_percent > 0)
+ {
+ $remise = round(($pu * $remise_percent / 100),2);
+ $price = ($pu - $remise);
+ }
- //Fetch current line from the database and then clone the object and set it in $oldline property
- $line = new OrderLine($this->db);
- $line->fetch($rowid);
+ //Fetch current line from the database and then clone the object and set it in $oldline property
+ $line = new OrderLine($this->db);
+ $line->fetch($rowid);
- if (!empty($line->fk_product))
- {
- $product=new Product($this->db);
- $result=$product->fetch($line->fk_product);
- $product_type=$product->type;
+ if (!empty($line->fk_product))
+ {
+ $product=new Product($this->db);
+ $result=$product->fetch($line->fk_product);
+ $product_type=$product->type;
- if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
- {
- $langs->load("errors");
- $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
- dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
- $this->db->rollback();
- return self::STOCK_NOT_ENOUGH_FOR_ORDER;
- }
- }
+ if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
+ dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return self::STOCK_NOT_ENOUGH_FOR_ORDER;
+ }
+ }
- $staticline = clone $line;
+ $staticline = clone $line;
- $line->oldline = $staticline;
- $this->line = $line;
- $this->line->context = $this->context;
+ $line->oldline = $staticline;
+ $this->line = $line;
+ $this->line->context = $this->context;
- // Reorder if fk_parent_line change
- if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
- {
- $rangmax = $this->line_max($fk_parent_line);
- $this->line->rang = $rangmax + 1;
- }
+ // Reorder if fk_parent_line change
+ if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
+ {
+ $rangmax = $this->line_max($fk_parent_line);
+ $this->line->rang = $rangmax + 1;
+ }
- $this->line->rowid=$rowid;
- $this->line->label=$label;
- $this->line->desc=$desc;
- $this->line->qty=$qty;
+ $this->line->rowid=$rowid;
+ $this->line->label=$label;
+ $this->line->desc=$desc;
+ $this->line->qty=$qty;
- $this->line->vat_src_code = $vat_src_code;
- $this->line->tva_tx = $txtva;
- $this->line->localtax1_tx = $txlocaltax1;
- $this->line->localtax2_tx = $txlocaltax2;
+ $this->line->vat_src_code = $vat_src_code;
+ $this->line->tva_tx = $txtva;
+ $this->line->localtax1_tx = $txlocaltax1;
+ $this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
- $this->line->remise_percent = $remise_percent;
- $this->line->subprice = $subprice;
- $this->line->info_bits = $info_bits;
- $this->line->special_code = $special_code;
- $this->line->total_ht = $total_ht;
- $this->line->total_tva = $total_tva;
- $this->line->total_localtax1= $total_localtax1;
- $this->line->total_localtax2= $total_localtax2;
- $this->line->total_ttc = $total_ttc;
- $this->line->date_start = $date_start;
- $this->line->date_end = $date_end;
- $this->line->product_type = $type;
- $this->line->fk_parent_line = $fk_parent_line;
- $this->line->skip_update_total=$skip_update_total;
- $this->line->fk_unit = $fk_unit;
+ $this->line->remise_percent = $remise_percent;
+ $this->line->subprice = $subprice;
+ $this->line->info_bits = $info_bits;
+ $this->line->special_code = $special_code;
+ $this->line->total_ht = $total_ht;
+ $this->line->total_tva = $total_tva;
+ $this->line->total_localtax1= $total_localtax1;
+ $this->line->total_localtax2= $total_localtax2;
+ $this->line->total_ttc = $total_ttc;
+ $this->line->date_start = $date_start;
+ $this->line->date_end = $date_end;
+ $this->line->product_type = $type;
+ $this->line->fk_parent_line = $fk_parent_line;
+ $this->line->skip_update_total=$skip_update_total;
+ $this->line->fk_unit = $fk_unit;
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
@@ -2966,44 +3026,44 @@ class Commande extends CommonOrder
// Multicurrency
$this->line->multicurrency_subprice = $pu_ht_devise;
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
- $this->line->multicurrency_total_tva = $multicurrency_total_tva;
- $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
+ $this->line->multicurrency_total_tva = $multicurrency_total_tva;
+ $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
- // TODO deprecated
- $this->line->price=$price;
- $this->line->remise=$remise;
+ // TODO deprecated
+ $this->line->price=$price;
+ $this->line->remise=$remise;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
- $result=$this->line->update($user, $notrigger);
- if ($result > 0)
- {
- // Reorder if child line
- if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
+ $result=$this->line->update($user, $notrigger);
+ if ($result > 0)
+ {
+ // Reorder if child line
+ if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
- // Mise a jour info denormalisees
- $this->update_price(1);
+ // Mise a jour info denormalisees
+ $this->update_price(1);
- $this->db->commit();
- return $result;
- }
- else
- {
- $this->error=$this->line->error;
+ $this->db->commit();
+ return $result;
+ }
+ else
+ {
+ $this->error=$this->line->error;
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=get_class($this)."::updateline Order status makes operation forbidden";
- $this->errors=array('OrderStatusMakeOperationForbidden');
- return -2;
- }
- }
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=get_class($this)."::updateline Order status makes operation forbidden";
+ $this->errors=array('OrderStatusMakeOperationForbidden');
+ return -2;
+ }
+ }
/**
* Update database
@@ -3065,17 +3125,23 @@ class Commande extends CommonOrder
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
- if (! $notrigger)
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY', $user);
- if ($result < 0) $error++;
- // End call triggers
+ $error++;
}
}
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
// Commit or rollback
if ($error)
{
@@ -3094,31 +3160,31 @@ class Commande extends CommonOrder
}
}
- /**
- * Delete the customer order
- *
- * @param User $user User object
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <=0 if KO, >0 if OK
- */
- function delete($user, $notrigger=0)
- {
- global $conf, $langs;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ /**
+ * Delete the customer order
+ *
+ * @param User $user User object
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <=0 if KO, >0 if OK
+ */
+ function delete($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $error = 0;
+ $error = 0;
- dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
+ dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
- $this->db->begin();
+ $this->db->begin();
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_DELETE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_DELETE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
if ($this->nb_expedition() != 0)
{
@@ -3126,311 +3192,318 @@ class Commande extends CommonOrder
$error++;
}
- if (! $error)
- {
- // Delete order details
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id;
- if (! $this->db->query($sql) )
- {
- $error++;
- $this->errors[]=$this->db->lasterror();
- }
- }
+ if (! $error)
+ {
+ // Delete order details
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id;
+ if (! $this->db->query($sql) )
+ {
+ $error++;
+ $this->errors[]=$this->db->lasterror();
+ }
+ }
- if (! $error)
- {
- // Delete linked object
- $res = $this->deleteObjectLinked();
- if ($res < 0) $error++;
- }
+ if (! $error)
+ {
+ // Delete linked object
+ $res = $this->deleteObjectLinked();
+ if ($res < 0) $error++;
+ }
- if (! $error)
- {
- // Delete linked contacts
- $res = $this->delete_linked_contact();
- if ($res < 0) $error++;
- }
+ if (! $error)
+ {
+ // Delete linked contacts
+ $res = $this->delete_linked_contact();
+ if ($res < 0) $error++;
+ }
- if (! $error)
- {
- // Remove extrafields
- if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
- {
- $result=$this->deleteExtraFields();
- if ($result < 0)
- {
- $error++;
- dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
- }
- }
- }
+ if (! $error)
+ {
+ // Remove extrafields
+ if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
+ {
+ $result=$this->deleteExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
+ }
+ }
+ }
- if (! $error)
- {
- // Delete object
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
- if (! $this->db->query($sql) )
- {
- $error++;
- $this->errors[]=$this->db->lasterror();
- }
- }
+ if (! $error)
+ {
+ // Delete object
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
+ if (! $this->db->query($sql) )
+ {
+ $error++;
+ $this->errors[]=$this->db->lasterror();
+ }
+ }
- if (! $error)
- {
- // Remove directory with files
- $comref = dol_sanitizeFileName($this->ref);
- if ($conf->commande->dir_output && !empty($this->ref))
- {
- $dir = $conf->commande->dir_output . "/" . $comref ;
- $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
- if (file_exists($file)) // We must delete all files before deleting directory
- {
- dol_delete_preview($this);
+ if (! $error)
+ {
+ // Remove directory with files
+ $comref = dol_sanitizeFileName($this->ref);
+ if ($conf->commande->dir_output && !empty($this->ref))
+ {
+ $dir = $conf->commande->dir_output . "/" . $comref ;
+ $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
+ if (file_exists($file)) // We must delete all files before deleting directory
+ {
+ dol_delete_preview($this);
- if (! dol_delete_file($file,0,0,0,$this)) // For triggers
- {
- $this->db->rollback();
- return 0;
- }
- }
- if (file_exists($dir))
- {
- if (! dol_delete_dir_recursive($dir))
- {
- $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
- $this->db->rollback();
- return 0;
- }
- }
- }
- }
+ if (! dol_delete_file($file,0,0,0,$this)) // For triggers
+ {
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ if (file_exists($dir))
+ {
+ if (! dol_delete_dir_recursive($dir))
+ {
+ $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ }
+ }
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
- /**
- * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
- *
- * @param User $user Object user
- * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
- */
- function load_board($user)
- {
- global $conf, $langs;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
+ *
+ * @param User $user Object user
+ * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
+ */
+ function load_board($user)
+ {
+ // phpcs:enable
+ global $conf, $langs;
- $clause = " WHERE";
+ $clause = " WHERE";
- $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
- if (!$user->rights->societe->client->voir && !$user->societe_id)
- {
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
- $clause = " AND";
- }
- $sql.= $clause." c.entity IN (".getEntity('commande').")";
- //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
- $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
- if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
+ $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut, c.total_ht";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
+ if (!$user->rights->societe->client->voir && !$user->societe_id)
+ {
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
+ $sql.= " WHERE sc.fk_user = " .$user->id;
+ $clause = " AND";
+ }
+ $sql.= $clause." c.entity IN (".getEntity('commande').")";
+ //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
+ $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
+ if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $response = new WorkboardResponse();
- $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
- $response->label=$langs->trans("OrdersToProcess");
- $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders';
- $response->img=img_object('',"order");
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $response = new WorkboardResponse();
+ $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
+ $response->label=$langs->trans("OrdersToProcess");
+ $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders';
+ $response->img=img_object('',"order");
- $generic_commande = new Commande($this->db);
+ $generic_commande = new Commande($this->db);
- while ($obj=$this->db->fetch_object($resql))
- {
- $response->nbtodo++;
+ while ($obj=$this->db->fetch_object($resql))
+ {
+ $response->nbtodo++;
+ $response->total+= $obj->total_ht;
- $generic_commande->statut = $obj->fk_statut;
- $generic_commande->date_commande = $this->db->jdate($obj->date_commande);
- $generic_commande->date_livraison = $this->db->jdate($obj->delivery_date);
+ $generic_commande->statut = $obj->fk_statut;
+ $generic_commande->date_commande = $this->db->jdate($obj->date_commande);
+ $generic_commande->date_livraison = $this->db->jdate($obj->delivery_date);
- if ($generic_commande->hasDelay()) {
- $response->nbtodolate++;
- }
- }
+ if ($generic_commande->hasDelay()) {
+ $response->nbtodolate++;
+ }
+ }
- return $response;
- }
- else
- {
- $this->error=$this->db->error();
- return -1;
- }
- }
+ return $response;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
- /**
- * Return source label of order
- *
- * @return string Label
- */
- function getLabelSource()
- {
- global $langs;
+ /**
+ * Return source label of order
+ *
+ * @return string Label
+ */
+ function getLabelSource()
+ {
+ global $langs;
- $label=$langs->trans('OrderSource'.$this->source);
+ $label=$langs->trans('OrderSource'.$this->source);
- if ($label == 'OrderSource') return '';
- return $label;
- }
+ if ($label == 'OrderSource') return '';
+ return $label;
+ }
- /**
- * Return status label of Order
- *
- * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label of status
- */
- function getLibStatut($mode)
- {
- return $this->LibStatut($this->statut, $this->billed, $mode);
- }
+ /**
+ * Return status label of Order
+ *
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ function getLibStatut($mode)
+ {
+ return $this->LibStatut($this->statut, $this->billed, $mode);
+ }
- /**
- * Return label of status
- *
- * @param int $statut Id statut
- * @param int $billed If invoiced
- * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
- * @param int $donotshowbilled Do not show billed status after order status
- * @return string Label of status
- */
- function LibStatut($statut,$billed,$mode,$donotshowbilled=0)
- {
- global $langs, $conf;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Return label of status
+ *
+ * @param int $statut Id statut
+ * @param int $billed If invoiced
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
+ * @param int $donotshowbilled Do not show billed status after order status
+ * @return string Label of status
+ */
+ function LibStatut($statut,$billed,$mode,$donotshowbilled=0)
+ {
+ // phpcs:enable
+ global $langs, $conf;
- $billedtext = '';
- if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):'');
+ $billedtext = '';
+ if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):'');
- //print 'x'.$statut.'-'.$billed;
- if ($mode == 0)
- {
- if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled');
- if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
- if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
- }
- elseif ($mode == 1)
- {
- if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
- if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
- if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
- }
- elseif ($mode == 2)
- {
- if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
- if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
- if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBillShort');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort');
- }
- elseif ($mode == 3)
- {
- if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
- if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
- if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6');
- }
- elseif ($mode == 4)
- {
- if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
- if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
- if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBill');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered');
- }
- elseif ($mode == 5)
- {
- if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
- if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
- if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
- }
- elseif ($mode == 6)
- {
- if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
- if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
- if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
- }
-
- }
+ //print 'x'.$statut.'-'.$billed;
+ if ($mode == 0)
+ {
+ if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled');
+ if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
+ if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
+ }
+ elseif ($mode == 1)
+ {
+ if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
+ if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
+ if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
+ }
+ elseif ($mode == 2)
+ {
+ if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
+ if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
+ if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBillShort');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort');
+ }
+ elseif ($mode == 3)
+ {
+ if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
+ if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
+ if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6');
+ }
+ elseif ($mode == 4)
+ {
+ if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
+ if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
+ if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBill');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered');
+ }
+ elseif ($mode == 5)
+ {
+ if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
+ if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
+ if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
+ }
+ elseif ($mode == 6)
+ {
+ if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
+ if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
+ if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
+ }
+ }
- /**
- * Return clicable link of object (with eventually picto)
- *
- * @param int $withpicto Add picto into link
- * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
- * @param int $max Max length to show
- * @param int $short ???
- * @param int $notooltip 1=Disable tooltip
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
- */
- function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
- {
- global $conf, $langs, $user;
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param int $withpicto Add picto into link
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param int $max Max length to show
+ * @param int $short ???
+ * @param int $notooltip 1=Disable tooltip
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
+ {
+ global $conf, $langs, $user;
- if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
+ if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
- $result='';
+ $result='';
- if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
- else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id;
+ if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
+ else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id;
- if ($option !== 'nolink')
- {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
- if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
- }
+ if (!$user->rights->commande->lire)
+ $option = 'nolink';
- if ($short) return $url;
+ if ($option !== 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
+ if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
+ }
- $label = '';
+ if ($short) return $url;
+
+ $label = '';
if ($user->rights->commande->lire) {
$label = ''.$langs->trans("ShowOrder").' ';
@@ -3450,225 +3523,232 @@ class Commande extends CommonOrder
$linkclose='';
if (empty($notooltip) && $user->rights->commande->lire)
{
- if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
- $label=$langs->trans("ShowOrder");
- $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose.=' class="classfortooltip"';
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label=$langs->trans("ShowOrder");
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose.=' class="classfortooltip"';
}
- $linkstart = '';
- $linkend=' ';
+ $linkstart = '';
+ $linkend=' ';
- $result .= $linkstart;
- if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
- if ($withpicto != 2) $result.= $this->ref;
- $result .= $linkend;
+ if ($option === 'nolink') {
+ $linkstart = '';
+ $linkend = '';
+ }
- return $result;
- }
+ $result .= $linkstart;
+ if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+ if ($withpicto != 2) $result.= $this->ref;
+ $result .= $linkend;
+
+ return $result;
+ }
- /**
- * Charge les informations d'ordre info dans l'objet commande
- *
- * @param int $id Id of order
- * @return void
- */
- function info($id)
- {
- $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,';
- $sql.= ' date_valid as datev,';
- $sql.= ' date_cloture as datecloture,';
- $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
- $sql.= ' WHERE c.rowid = '.$id;
- $result=$this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
- $obj = $this->db->fetch_object($result);
- $this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
- $cuser = new User($this->db);
- $cuser->fetch($obj->fk_user_author);
- $this->user_creation = $cuser;
- }
+ /**
+ * Charge les informations d'ordre info dans l'objet commande
+ *
+ * @param int $id Id of order
+ * @return void
+ */
+ function info($id)
+ {
+ $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,';
+ $sql.= ' date_valid as datev,';
+ $sql.= ' date_cloture as datecloture,';
+ $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
+ $sql.= ' WHERE c.rowid = '.$id;
+ $result=$this->db->query($sql);
+ if ($result)
+ {
+ if ($this->db->num_rows($result))
+ {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author)
+ {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
- if ($obj->fk_user_valid)
- {
- $vuser = new User($this->db);
- $vuser->fetch($obj->fk_user_valid);
- $this->user_validation = $vuser;
- }
+ if ($obj->fk_user_valid)
+ {
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
+ $this->user_validation = $vuser;
+ }
- if ($obj->fk_user_cloture)
- {
- $cluser = new User($this->db);
- $cluser->fetch($obj->fk_user_cloture);
- $this->user_cloture = $cluser;
- }
+ if ($obj->fk_user_cloture)
+ {
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
+ $this->user_cloture = $cluser;
+ }
- $this->date_creation = $this->db->jdate($obj->datec);
- $this->date_modification = $this->db->jdate($obj->datem);
- $this->date_validation = $this->db->jdate($obj->datev);
- $this->date_cloture = $this->db->jdate($obj->datecloture);
- }
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_modification = $this->db->jdate($obj->datem);
+ $this->date_validation = $this->db->jdate($obj->datev);
+ $this->date_cloture = $this->db->jdate($obj->datecloture);
+ }
- $this->db->free($result);
+ $this->db->free($result);
- }
- else
- {
- dol_print_error($this->db);
- }
- }
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+ }
- /**
- * Initialise an instance with random values.
- * Used to build previews or test instances.
- * id must be 0 if object instance is a specimen.
- *
- * @return void
- */
- function initAsSpecimen()
- {
- global $langs;
+ /**
+ * Initialise an instance with random values.
+ * Used to build previews or test instances.
+ * id must be 0 if object instance is a specimen.
+ *
+ * @return void
+ */
+ function initAsSpecimen()
+ {
+ global $langs;
- dol_syslog(get_class($this)."::initAsSpecimen");
+ dol_syslog(get_class($this)."::initAsSpecimen");
- // Load array of products prodids
- $num_prods = 0;
- $prodids = array();
- $sql = "SELECT rowid";
- $sql.= " FROM ".MAIN_DB_PREFIX."product";
- $sql.= " WHERE entity IN (".getEntity('product').")";
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num_prods = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num_prods)
- {
- $i++;
- $row = $this->db->fetch_row($resql);
- $prodids[$i] = $row[0];
- }
- }
+ // Load array of products prodids
+ $num_prods = 0;
+ $prodids = array();
+ $sql = "SELECT rowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product";
+ $sql.= " WHERE entity IN (".getEntity('product').")";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num_prods = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_prods)
+ {
+ $i++;
+ $row = $this->db->fetch_row($resql);
+ $prodids[$i] = $row[0];
+ }
+ }
- // Initialise parametres
- $this->id=0;
- $this->ref = 'SPECIMEN';
- $this->specimen=1;
- $this->socid = 1;
- $this->date = time();
- $this->date_lim_reglement=$this->date+3600*24*30;
- $this->cond_reglement_code = 'RECEP';
- $this->mode_reglement_code = 'CHQ';
- $this->availability_code = 'DSP';
- $this->demand_reason_code = 'SRC_00';
- $this->note_public='This is a comment (public)';
- $this->note_private='This is a comment (private)';
- // Lines
- $nbp = 5;
- $xnbp = 0;
- while ($xnbp < $nbp)
- {
- $line=new OrderLine($this->db);
+ // Initialise parametres
+ $this->id=0;
+ $this->ref = 'SPECIMEN';
+ $this->specimen=1;
+ $this->socid = 1;
+ $this->date = time();
+ $this->date_lim_reglement=$this->date+3600*24*30;
+ $this->cond_reglement_code = 'RECEP';
+ $this->mode_reglement_code = 'CHQ';
+ $this->availability_code = 'DSP';
+ $this->demand_reason_code = 'SRC_00';
+ $this->note_public='This is a comment (public)';
+ $this->note_private='This is a comment (private)';
+ // Lines
+ $nbp = 5;
+ $xnbp = 0;
+ while ($xnbp < $nbp)
+ {
+ $line=new OrderLine($this->db);
- $line->desc=$langs->trans("Description")." ".$xnbp;
- $line->qty=1;
- $line->subprice=100;
- $line->price=100;
- $line->tva_tx=20;
- if ($xnbp == 2)
- {
- $line->total_ht=50;
- $line->total_ttc=60;
- $line->total_tva=10;
- $line->remise_percent=50;
- }
- else
- {
- $line->total_ht=100;
- $line->total_ttc=120;
- $line->total_tva=20;
- $line->remise_percent=0;
- }
- if ($num_prods > 0)
- {
- $prodid = mt_rand(1, $num_prods);
- $line->fk_product=$prodids[$prodid];
+ $line->desc=$langs->trans("Description")." ".$xnbp;
+ $line->qty=1;
+ $line->subprice=100;
+ $line->price=100;
+ $line->tva_tx=20;
+ if ($xnbp == 2)
+ {
+ $line->total_ht=50;
+ $line->total_ttc=60;
+ $line->total_tva=10;
+ $line->remise_percent=50;
+ }
+ else
+ {
+ $line->total_ht=100;
+ $line->total_ttc=120;
+ $line->total_tva=20;
+ $line->remise_percent=0;
+ }
+ if ($num_prods > 0)
+ {
+ $prodid = mt_rand(1, $num_prods);
+ $line->fk_product=$prodids[$prodid];
$line->product_ref='SPECIMEN';
- }
+ }
- $this->lines[$xnbp]=$line;
+ $this->lines[$xnbp]=$line;
- $this->total_ht += $line->total_ht;
- $this->total_tva += $line->total_tva;
- $this->total_ttc += $line->total_ttc;
+ $this->total_ht += $line->total_ht;
+ $this->total_tva += $line->total_tva;
+ $this->total_ttc += $line->total_ttc;
- $xnbp++;
- }
- }
+ $xnbp++;
+ }
+ }
- /**
- * Charge indicateurs this->nb de tableau de bord
- *
- * @return int <0 si ko, >0 si ok
- */
- function load_state_board()
- {
- global $user;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Charge indicateurs this->nb de tableau de bord
+ *
+ * @return int <0 si ko, >0 si ok
+ */
+ function load_state_board()
+ {
+ // phpcs:enable
+ global $user;
- $this->nb=array();
- $clause = "WHERE";
+ $this->nb=array();
+ $clause = "WHERE";
- $sql = "SELECT count(co.rowid) as nb";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande as co";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$user->societe_id)
- {
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
- $clause = "AND";
- }
- $sql.= " ".$clause." co.entity IN (".getEntity('commande').")";
+ $sql = "SELECT count(co.rowid) as nb";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande as co";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
+ if (!$user->rights->societe->client->voir && !$user->societe_id)
+ {
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
+ $sql.= " WHERE sc.fk_user = " .$user->id;
+ $clause = "AND";
+ }
+ $sql.= " ".$clause." co.entity IN (".getEntity('commande').")";
- $resql=$this->db->query($sql);
- if ($resql)
- {
- while ($obj=$this->db->fetch_object($resql))
- {
- $this->nb["orders"]=$obj->nb;
- }
- $this->db->free($resql);
- return 1;
- }
- else
- {
- dol_print_error($this->db);
- $this->error=$this->db->error();
- return -1;
- }
- }
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ while ($obj=$this->db->fetch_object($resql))
+ {
+ $this->nb["orders"]=$obj->nb;
+ }
+ $this->db->free($resql);
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
- /**
+ /**
* Create an array of order lines
*
* @return int >0 if OK, <0 if KO
- */
- function getLinesArray()
- {
- return $this->fetch_lines();
- }
+ */
+ function getLinesArray()
+ {
+ return $this->fetch_lines();
+ }
/**
* Create a document onto disk according to template module.
@@ -3678,7 +3758,7 @@ class Commande extends CommonOrder
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
- * @param null|array $moreparams Array to provide more information
+ * @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
@@ -3715,45 +3795,45 @@ class Commande extends CommonOrder
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
- 'commande'
+ 'commande'
);
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
- /**
- * Is the customer order delayed?
- *
- * @return bool true if late, false if not
- */
- public function hasDelay()
- {
- global $conf;
+ /**
+ * Is the customer order delayed?
+ *
+ * @return bool true if late, false if not
+ */
+ public function hasDelay()
+ {
+ global $conf;
- if (! ($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) {
- return false; // Never late if not inside this status range
- }
+ if (! ($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) {
+ return false; // Never late if not inside this status range
+ }
- $now = dol_now();
+ $now = dol_now();
- return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
- }
+ return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
+ }
- /**
- * Show the customer delayed info
- *
- * @return string Show delayed information
- */
- public function showDelay()
- {
- global $conf, $langs;
+ /**
+ * Show the customer delayed info
+ *
+ * @return string Show delayed information
+ */
+ public function showDelay()
+ {
+ global $conf, $langs;
- if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
- else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day');
- $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today");
+ if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
+ else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day');
+ $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today");
- return $text;
- }
+ return $text;
+ }
}
@@ -3762,10 +3842,14 @@ class Commande extends CommonOrder
*/
class OrderLine extends CommonOrderLine
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='commandedet';
+
public $table_element='commandedet';
- var $oldline;
+ var $oldline;
/**
* Id of parent order
@@ -3781,12 +3865,17 @@ class OrderLine extends CommonOrderLine
*/
public $commande_id;
- // From llx_commandedet
- var $fk_parent_line;
- var $fk_facture;
- var $label;
- var $fk_remise_except;
- var $rang = 0;
+ // From llx_commandedet
+ var $fk_parent_line;
+ var $fk_facture;
+
+ /**
+ * @var string Order lines label
+ */
+ public $label;
+
+ var $fk_remise_except;
+ var $rang = 0;
var $fk_fournprice;
/**
@@ -3794,8 +3883,8 @@ class OrderLine extends CommonOrderLine
* @var float
*/
var $pa_ht;
- var $marge_tx;
- var $marque_tx;
+ var $marge_tx;
+ var $marque_tx;
/**
* @deprecated
@@ -3803,88 +3892,89 @@ class OrderLine extends CommonOrderLine
*/
var $remise;
- // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- // Start and end date of the line
- var $date_start;
- var $date_end;
+ // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ // Start and end date of the line
+ var $date_start;
+ var $date_end;
- var $skip_update_total; // Skip update price total for special lines
+ var $skip_update_total; // Skip update price total for special lines
- /**
- * Constructor
- *
- * @param DoliDB $db handler d'acces base de donnee
- */
- function __construct($db)
- {
- $this->db= $db;
- }
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db handler d'acces base de donnee
+ */
+ function __construct($db)
+ {
+ $this->db= $db;
+ }
- /**
- * Load line order
- *
- * @param int $rowid Id line order
- * @return int <0 if KO, >0 if OK
- */
- function fetch($rowid)
- {
- $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
- $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
- $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
- $sql.= ' cd.fk_unit,';
+ /**
+ * Load line order
+ *
+ * @param int $rowid Id line order
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch($rowid)
+ {
+ $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
+ $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
+ $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
+ $sql.= ' cd.fk_unit,';
$sql.= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,';
- $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,';
- $sql.= ' cd.date_start, cd.date_end';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
- $sql.= ' WHERE cd.rowid = '.$rowid;
- $result = $this->db->query($sql);
- if ($result)
- {
- $objp = $this->db->fetch_object($result);
- $this->rowid = $objp->rowid;
- $this->fk_commande = $objp->fk_commande;
- $this->fk_parent_line = $objp->fk_parent_line;
- $this->label = $objp->custom_label;
- $this->desc = $objp->description;
- $this->qty = $objp->qty;
- $this->price = $objp->price;
- $this->subprice = $objp->subprice;
- $this->vat_src_code = $objp->vat_src_code;
- $this->tva_tx = $objp->tva_tx;
- $this->localtax1_tx = $objp->localtax1_tx;
- $this->localtax2_tx = $objp->localtax2_tx;
- $this->remise = $objp->remise;
- $this->remise_percent = $objp->remise_percent;
- $this->fk_remise_except = $objp->fk_remise_except;
- $this->fk_product = $objp->fk_product;
- $this->product_type = $objp->product_type;
- $this->info_bits = $objp->info_bits;
+ $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,';
+ $sql.= ' cd.date_start, cd.date_end';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
+ $sql.= ' WHERE cd.rowid = '.$rowid;
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $objp = $this->db->fetch_object($result);
+ $this->rowid = $objp->rowid;
+ $this->id = $objp->rowid;
+ $this->fk_commande = $objp->fk_commande;
+ $this->fk_parent_line = $objp->fk_parent_line;
+ $this->label = $objp->custom_label;
+ $this->desc = $objp->description;
+ $this->qty = $objp->qty;
+ $this->price = $objp->price;
+ $this->subprice = $objp->subprice;
+ $this->vat_src_code = $objp->vat_src_code;
+ $this->tva_tx = $objp->tva_tx;
+ $this->localtax1_tx = $objp->localtax1_tx;
+ $this->localtax2_tx = $objp->localtax2_tx;
+ $this->remise = $objp->remise;
+ $this->remise_percent = $objp->remise_percent;
+ $this->fk_remise_except = $objp->fk_remise_except;
+ $this->fk_product = $objp->fk_product;
+ $this->product_type = $objp->product_type;
+ $this->info_bits = $objp->info_bits;
$this->special_code = $objp->special_code;
- $this->total_ht = $objp->total_ht;
- $this->total_tva = $objp->total_tva;
- $this->total_localtax1 = $objp->total_localtax1;
- $this->total_localtax2 = $objp->total_localtax2;
- $this->total_ttc = $objp->total_ttc;
+ $this->total_ht = $objp->total_ht;
+ $this->total_tva = $objp->total_tva;
+ $this->total_localtax1 = $objp->total_localtax1;
+ $this->total_localtax2 = $objp->total_localtax2;
+ $this->total_ttc = $objp->total_ttc;
$this->fk_fournprice = $objp->fk_fournprice;
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
$this->pa_ht = $marginInfos[0];
$this->marge_tx = $marginInfos[1];
$this->marque_tx = $marginInfos[2];
- $this->special_code = $objp->special_code;
- $this->rang = $objp->rang;
+ $this->special_code = $objp->special_code;
+ $this->rang = $objp->rang;
- $this->ref = $objp->product_ref; // deprecated
- $this->product_ref = $objp->product_ref;
- $this->libelle = $objp->product_libelle; // deprecated
- $this->product_label = $objp->product_libelle;
- $this->product_desc = $objp->product_desc;
- $this->product_tobatch = $objp->product_tobatch;
- $this->fk_unit = $objp->fk_unit;
+ $this->ref = $objp->product_ref; // deprecated
+ $this->product_ref = $objp->product_ref;
+ $this->libelle = $objp->product_libelle; // deprecated
+ $this->product_label = $objp->product_libelle;
+ $this->product_desc = $objp->product_desc;
+ $this->product_tobatch = $objp->product_tobatch;
+ $this->fk_unit = $objp->fk_unit;
- $this->date_start = $this->db->jdate($objp->date_start);
- $this->date_end = $this->db->jdate($objp->date_end);
+ $this->date_start = $this->db->jdate($objp->date_start);
+ $this->date_end = $this->db->jdate($objp->date_end);
$this->fk_multicurrency = $objp->fk_multicurrency;
$this->multicurrency_code = $objp->multicurrency_code;
@@ -3893,38 +3983,38 @@ class OrderLine extends CommonOrderLine
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
- $this->db->free($result);
+ $this->db->free($result);
- return 1;
- }
- else
- {
- $this->error = $this->db->lasterror();
- return -1;
- }
- }
+ return 1;
+ }
+ else
+ {
+ $this->error = $this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Delete line in database
- *
- * @param User $user User that modify
+ /**
+ * Delete line in database
+ *
+ * @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
- * @return int <0 si ko, >0 si ok
- */
- function delete($user=null, $notrigger=0)
- {
- global $conf, $user, $langs;
+ * @return int <0 si ko, >0 si ok
+ */
+ function delete($user=null, $notrigger=0)
+ {
+ global $conf, $user, $langs;
$error=0;
- $this->db->begin();
+ $this->db->begin();
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid=".$this->rowid;
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid=".$this->rowid;
- dol_syslog("OrderLine::delete", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
+ dol_syslog("OrderLine::delete", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
// Remove extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
@@ -3939,63 +4029,63 @@ class OrderLine extends CommonOrderLine
if (! $error && ! $notrigger)
{
- // Call trigger
- $result=$this->call_trigger('LINEORDER_DELETE',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('LINEORDER_DELETE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
- if (!$error) {
- $this->db->commit();
- return 1;
- }
+ if (!$error) {
+ $this->db->commit();
+ return 1;
+ }
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Insert line into database
- *
- * @param User $user User that modify
- * @param int $notrigger 1 = disable triggers
- * @return int <0 if KO, >0 if OK
- */
- function insert($user=null, $notrigger=0)
- {
- global $langs, $conf;
+ /**
+ * Insert line into database
+ *
+ * @param User $user User that modify
+ * @param int $notrigger 1 = disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function insert($user=null, $notrigger=0)
+ {
+ global $langs, $conf;
$error=0;
- $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
+ $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
- dol_syslog(get_class($this)."::insert rang=".$this->rang);
+ dol_syslog(get_class($this)."::insert rang=".$this->rang);
- // Clean parameters
- if (empty($this->tva_tx)) $this->tva_tx=0;
- if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
- if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
+ // Clean parameters
+ if (empty($this->tva_tx)) $this->tva_tx=0;
+ if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
+ if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->localtax1_type)) $this->localtax1_type=0;
if (empty($this->localtax2_type)) $this->localtax2_type=0;
- if (empty($this->total_localtax1)) $this->total_localtax1=0;
- if (empty($this->total_localtax2)) $this->total_localtax2=0;
- if (empty($this->rang)) $this->rang=0;
- if (empty($this->remise)) $this->remise=0;
- if (empty($this->remise_percent)) $this->remise_percent=0;
- if (empty($this->info_bits)) $this->info_bits=0;
- if (empty($this->special_code)) $this->special_code=0;
- if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
+ if (empty($this->total_localtax1)) $this->total_localtax1=0;
+ if (empty($this->total_localtax2)) $this->total_localtax2=0;
+ if (empty($this->rang)) $this->rang=0;
+ if (empty($this->remise)) $this->remise=0;
+ if (empty($this->remise_percent)) $this->remise_percent=0;
+ if (empty($this->info_bits)) $this->info_bits=0;
+ if (empty($this->special_code)) $this->special_code=0;
+ if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
@@ -4011,65 +4101,65 @@ class OrderLine extends CommonOrderLine
}
}
- // Check parameters
- if ($this->product_type < 0) return -1;
+ // Check parameters
+ if ($this->product_type < 0) return -1;
- $this->db->begin();
+ $this->db->begin();
- // Insertion dans base de la ligne
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
- $sql.= ' (fk_commande, fk_parent_line, label, description, qty, ';
- $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
- $sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
- $sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
- $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
- $sql.= ' fk_unit';
+ // Insertion dans base de la ligne
+ $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
+ $sql.= ' (fk_commande, fk_parent_line, label, description, qty, ';
+ $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
+ $sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
+ $sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
+ $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
+ $sql.= ' fk_unit';
$sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
$sql.= ')';
- $sql.= " VALUES (".$this->fk_commande.",";
- $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").",";
- $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
- $sql.= " '".$this->db->escape($this->desc)."',";
- $sql.= " '".price2num($this->qty)."',";
- $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").",";
- $sql.= " '".price2num($this->tva_tx)."',";
- $sql.= " '".price2num($this->localtax1_tx)."',";
- $sql.= " '".price2num($this->localtax2_tx)."',";
+ $sql.= " VALUES (".$this->fk_commande.",";
+ $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").",";
+ $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
+ $sql.= " '".$this->db->escape($this->desc)."',";
+ $sql.= " '".price2num($this->qty)."',";
+ $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").",";
+ $sql.= " '".price2num($this->tva_tx)."',";
+ $sql.= " '".price2num($this->localtax1_tx)."',";
+ $sql.= " '".price2num($this->localtax2_tx)."',";
$sql.= " '".$this->db->escape($this->localtax1_type)."',";
$sql.= " '".$this->db->escape($this->localtax2_type)."',";
- $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
- $sql.= " '".$this->db->escape($this->product_type)."',";
- $sql.= " '".price2num($this->remise_percent)."',";
- $sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").",";
- $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
- $sql.= " '".price2num($this->remise)."',";
- $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").',';
- $sql.= ' '.$this->special_code.',';
- $sql.= ' '.$this->rang.',';
+ $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
+ $sql.= " '".$this->db->escape($this->product_type)."',";
+ $sql.= " '".price2num($this->remise_percent)."',";
+ $sql.= " ".(price2num($this->subprice)!==''?price2num($this->subprice):"null").",";
+ $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
+ $sql.= " '".price2num($this->remise)."',";
+ $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").',';
+ $sql.= ' '.$this->special_code.',';
+ $sql.= ' '.$this->rang.',';
$sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").',';
$sql.= ' '.price2num($this->pa_ht).',';
- $sql.= " '".$this->db->escape($this->info_bits)."',";
- $sql.= " '".price2num($this->total_ht)."',";
- $sql.= " '".price2num($this->total_tva)."',";
- $sql.= " '".price2num($this->total_localtax1)."',";
- $sql.= " '".price2num($this->total_localtax2)."',";
- $sql.= " '".price2num($this->total_ttc)."',";
- $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
- $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").',';
- $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit);
+ $sql.= " '".$this->db->escape($this->info_bits)."',";
+ $sql.= " ".price2num($this->total_ht).",";
+ $sql.= " ".price2num($this->total_tva).",";
+ $sql.= " ".price2num($this->total_localtax1).",";
+ $sql.= " ".price2num($this->total_localtax2).",";
+ $sql.= " ".price2num($this->total_ttc).",";
+ $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
+ $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").',';
+ $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", ".(! empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL');
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".$this->multicurrency_subprice;
$sql.= ", ".$this->multicurrency_total_ht;
$sql.= ", ".$this->multicurrency_total_tva;
$sql.= ", ".$this->multicurrency_total_ttc;
- $sql.= ')';
+ $sql.= ')';
- dol_syslog(get_class($this)."::insert", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
+ dol_syslog(get_class($this)."::insert", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
@@ -4081,42 +4171,42 @@ class OrderLine extends CommonOrderLine
}
}
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('LINEORDER_INSERT',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('LINEORDER_INSERT',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- if (!$error) {
- $this->db->commit();
- return 1;
- }
+ if (!$error) {
+ $this->db->commit();
+ return 1;
+ }
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -2;
- }
- }
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -2;
+ }
+ }
- /**
- * Update the line object into db
- *
- * @param User $user User that modify
+ /**
+ * Update the line object into db
+ *
+ * @param User $user User that modify
* @param int $notrigger 1 = disable triggers
- * @return int <0 si ko, >0 si ok
- */
+ * @return int <0 si ko, >0 si ok
+ */
function update(User $user, $notrigger=0)
{
global $conf,$langs;
@@ -4139,7 +4229,7 @@ class OrderLine extends CommonOrderLine
if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
- if (empty($this->special_code)) $this->special_code=0;
+ if (empty($this->special_code)) $this->special_code=0;
if (empty($this->product_type)) $this->product_type=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
@@ -4185,7 +4275,7 @@ class OrderLine extends CommonOrderLine
$sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?$this->fk_fournprice:"null");
$sql.= " , buy_price_ht='".price2num($this->pa_ht)."'";
$sql.= " , info_bits=".$this->info_bits;
- $sql.= " , special_code=".$this->special_code;
+ $sql.= " , special_code=".$this->special_code;
$sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
$sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= " , product_type=".$this->product_type;
@@ -4195,9 +4285,9 @@ class OrderLine extends CommonOrderLine
// Multicurrency
$sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice)."";
- $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
- $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
- $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
+ $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
+ $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
+ $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
$sql.= " WHERE rowid = ".$this->rowid;
@@ -4217,10 +4307,10 @@ class OrderLine extends CommonOrderLine
if (! $error && ! $notrigger)
{
- // Call trigger
- $result=$this->call_trigger('LINEORDER_UPDATE',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('LINEORDER_UPDATE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
if (!$error) {
@@ -4244,42 +4334,44 @@ class OrderLine extends CommonOrderLine
}
}
- /**
- * Update totals of order into database
- *
- * @return int <0 if ko, >0 if ok
- */
- function update_total()
- {
- $this->db->begin();
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Update DB line fields total_xxx
+ * Used by migration
+ *
+ * @return int <0 if KO, >0 if OK
+ */
+ function update_total()
+ {
+ // phpcs:enable
+ $this->db->begin();
- // Clean parameters
- if (empty($this->total_localtax1)) $this->total_localtax1=0;
- if (empty($this->total_localtax2)) $this->total_localtax2=0;
+ // Clean parameters
+ if (empty($this->total_localtax1)) $this->total_localtax1=0;
+ if (empty($this->total_localtax2)) $this->total_localtax2=0;
- // Mise a jour ligne en base
- $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
- $sql.= " total_ht='".price2num($this->total_ht)."'";
- $sql.= ",total_tva='".price2num($this->total_tva)."'";
- $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'";
- $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'";
- $sql.= ",total_ttc='".price2num($this->total_ttc)."'";
- $sql.= " WHERE rowid = ".$this->rowid;
+ // Mise a jour ligne en base
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
+ $sql.= " total_ht='".price2num($this->total_ht)."'";
+ $sql.= ",total_tva='".price2num($this->total_tva)."'";
+ $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'";
+ $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'";
+ $sql.= ",total_ttc='".price2num($this->total_ttc)."'";
+ $sql.= " WHERE rowid = ".$this->rowid;
- dol_syslog("OrderLine::update_total", LOG_DEBUG);
+ dol_syslog("OrderLine::update_total", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -2;
- }
- }
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -2;
+ }
+ }
}
-
diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php
index 6d9dde94bc4..13d7e245f05 100644
--- a/htdocs/commande/class/commandestats.class.php
+++ b/htdocs/commande/class/commandestats.class.php
@@ -34,6 +34,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
*/
class CommandeStats extends Stats
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element;
var $socid;
@@ -219,6 +222,5 @@ class CommandeStats extends Stats
return $this->_getAllByProduct($sql);
}
-
}
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 7669239134a..bd00116e026 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -214,5 +214,6 @@ if ($id > 0 || ! empty($ref))
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php
index 9263ceb3f45..42def36ee28 100644
--- a/htdocs/commande/customer.php
+++ b/htdocs/commande/customer.php
@@ -190,7 +190,7 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index ffebbaa260a..fc8192f7edb 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref))
$head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -189,6 +189,6 @@ else
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php
index 5cfb87c7a25..4c596620c6c 100644
--- a/htdocs/commande/index.php
+++ b/htdocs/commande/index.php
@@ -479,6 +479,6 @@ if (! empty($conf->commande->enabled))
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php
index 4bac4a3a447..6c0b5f42ec6 100644
--- a/htdocs/commande/info.php
+++ b/htdocs/commande/info.php
@@ -128,5 +128,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index a63847421eb..558d8186a86 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -1,15 +1,15 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012 Juanjo Menent
- * Copyright (C) 2013 Christophe Battarel
- * Copyright (C) 2013 Cédric Salvador
- * Copyright (C) 2015 Frederic France
- * Copyright (C) 2015 Marcos García
- * Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2016 Ferran Marcet
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Juanjo Menent
+ * Copyright (C) 2013 Christophe Battarel
+ * Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2015-2018 Frédéric France
+ * Copyright (C) 2015 Marcos García
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2016 Ferran Marcet
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -78,6 +78,9 @@ $search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
$optioncss = GETPOST('optioncss','alpha');
$billed = GETPOST('billed','int');
$viewstatut=GETPOST('viewstatut');
+$search_btn=GETPOST('button_search','alpha');
+$search_remove_btn=GETPOST('button_removefilter','alpha');
+$search_project_ref=GETPOST('search_project_ref','alpha');
// Security check
$id = (GETPOST('orderid')?GETPOST('orderid','int'):GETPOST('id','int'));
@@ -91,7 +94,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -484,7 +487,7 @@ if ($resql)
print $langs->trans('DateInvoice');
print '';
print '';
- print $form->select_date('', '', '', '', '', '', 1, 1);
+ print $form->selectDate('', '', '', '', '', '', 1, 1);
print ' ';
print ' ';
print '';
@@ -509,7 +512,7 @@ if ($resql)
{
print $form->selectyesno('valdate_invoices', 0, 1);
}
- if (! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print ' '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").' ';
+ if (! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print ' '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").' ';
else print ' '.$langs->trans("OptionToSetOrderBilledNotEnabled").' ';
print '';
print ' ';
@@ -1160,5 +1163,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php
index 6cff3bfb3bc..bf02c9b993c 100644
--- a/htdocs/commande/note.php
+++ b/htdocs/commande/note.php
@@ -142,5 +142,6 @@ if ($id > 0 || ! empty($ref))
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index 03d379270b1..3335cf93276 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2004-2013 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012 Andreu Bisquerra Gaya
- * Copyright (C) 2012 David Rodriguez Martinez
- * Copyright (C) 2012-2018 Juanjo Menent
- * Copyright (C) 2015 Ferran Marcet
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Andreu Bisquerra Gaya
+ * Copyright (C) 2012 David Rodriguez Martinez
+ * Copyright (C) 2012-2018 Juanjo Menent
+ * Copyright (C) 2015 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -442,7 +443,7 @@ if ($action == 'create' && !$error)
// Date invoice
print ''.$langs->trans('Date').' ';
- $html->select_date('','','','','',"add",1,1);
+ print $html->selectDate('', '', '', '', '', "add", 1, 1);
print ' ';
// Payment term
print ''.$langs->trans('PaymentConditionsShort').' ';
@@ -596,8 +597,8 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
$num = $db->num_rows($resql);
print load_fiche_titre($title);
$i = 0;
- $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1);
- $periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1);
+ $period=$html->selectDate($date_start,'date_start',0,0,1,'',1,0).' - '.$html->selectDate($date_end,'date_end',0,0,1,'',1,0);
+ $periodely=$html->selectDate($date_starty,'date_start_dely',0,0,1,'',1,0).' - '.$html->selectDate($date_endy,'date_end_dely',0,0,1,'',1,0);
if (! empty($socid))
{
@@ -654,7 +655,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print '';
print '';
-
+
$generic_commande = new Commande($db);
while ($i < $num)
@@ -739,5 +740,6 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php
index 8f259808357..49e7d5cfb60 100644
--- a/htdocs/commande/stats/index.php
+++ b/htdocs/commande/stats/index.php
@@ -369,7 +369,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php
index a786cf5ca28..5e1a10390e2 100644
--- a/htdocs/compta/bank/annuel.php
+++ b/htdocs/compta/bank/annuel.php
@@ -24,7 +24,7 @@
* \brief Page to report input-output of a bank account
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@@ -494,5 +494,6 @@ else
print "\n \n";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 72f4bbbd988..311335fd96b 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -8,6 +8,7 @@
* Copyright (C) 2016 Juanjo Menent
* Copyright (C) 2017 Alexandre Spangaro
* Copyright (C) 2018 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +30,7 @@
* \brief List of bank transactions
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -103,7 +104,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (! $sortorder) $sortorder='ASC';
+if (! $sortorder) $sortorder='desc,desc,desc';
if (! $sortfield) $sortfield='b.datev,b.dateo,b.rowid';
$mode_balance_ok=false;
@@ -113,7 +114,6 @@ if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid'))
$sortfield = 'b.datev,b.dateo,b.rowid';
if ($id > 0 || ! empty($ref) || $search_account > 0) $mode_balance_ok = true;
}
-if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
$object = new Account($db);
if ($id > 0 || ! empty($ref))
@@ -445,7 +445,7 @@ $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappr
$sql.= " b.fk_account, b.fk_type,";
$sql.= " ba.rowid as bankid, ba.ref as bankref,";
$sql.= " bu.url_id,";
-$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
+$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@@ -526,8 +526,8 @@ if (! empty($debit)) $mode_balance_ok=false;
if (! empty($credit)) $mode_balance_ok=false;
if (! empty($thirdparty)) $mode_balance_ok=false;
-$sql.= $db->plimit($limit+1,$offset);
-
+$sql.= $db->plimit($limit+1, $offset);
+//print $sql;
dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
@@ -667,7 +667,7 @@ if ($resql)
}
print ' ';
print '';
- $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction');
+ print $form->selectDate(empty($dateop)?-1:$dateop, 'op', 0, 0, 0, 'transaction');
print ' ';
print ' ';
print '';
@@ -788,17 +788,17 @@ if ($resql)
$moreforfilter.='';
$moreforfilter .= $langs->trans('DateOperationShort').' : ';
$moreforfilter .= '
'.$langs->trans('From') . ' ';
- $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1).'
';
+ $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'
';
//$moreforfilter .= ' - ';
- $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'
';
+ $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'
';
$moreforfilter .= '';
$moreforfilter.='';
$moreforfilter .= $langs->trans('DateValueShort').' : ';
$moreforfilter .= '
'.$langs->trans('From') . ' ';
- $moreforfilter .= $form->select_date($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 1).'
';
+ $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'
';
//$moreforfilter .= ' - ';
- $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'
';
+ $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'
';
$moreforfilter .= '';
if (! empty($conf->categorie->enabled))
@@ -950,7 +950,8 @@ if ($resql)
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
print " \n";
- $balance = 0; // For balance
+ $balance = 0; // For balance
+ $balancebefore = 0; // For balance
$balancecalculated = false;
$posconciliatecol = 0;
@@ -974,7 +975,7 @@ if ($resql)
// Loop on each record before
$sign = 1;
$i = 0;
- $sqlforbalance='SELECT SUM(b.amount) as balance';
+ $sqlforbalance='SELECT SUM(b.amount) as previoustotal';
$sqlforbalance.= " FROM ";
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,";
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b";
@@ -989,7 +990,16 @@ if ($resql)
$objforbalance = $db->fetch_object($resqlforbalance);
if ($objforbalance)
{
- $balance = $objforbalance->balance;
+ // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
+ if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc')
+ {
+ $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
+ }
+ // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
+ else
+ {
+ $balance = $objforbalance->previoustotal;
+ }
}
}
else dol_print_error($db);
@@ -1065,7 +1075,17 @@ if ($resql)
}
}
- $balance = price2num($balance + ($sign * $objp->amount),'MT');
+
+ if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc')
+ {
+ $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
+ $balancebefore = price2num($balancebefore - ($sign * $objp->amount),'MT');
+ }
+ else
+ {
+ $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc)
+ $balance = price2num($balance + ($sign * $objp->amount),'MT');
+ }
if (empty($cachebankaccount[$objp->bankid]))
{
@@ -1285,6 +1305,7 @@ if ($resql)
$companystatic->name=$objp->nom;
$companystatic->name_alias=$objp->name_alias;
$companystatic->client=$objp->client;
+ $companystatic->email=$objp->email;
$companystatic->fournisseur=$objp->fournisseur;
$companystatic->code_client=$objp->code_client;
$companystatic->code_fournisseur=$objp->code_fournisseur;
@@ -1342,7 +1363,6 @@ if ($resql)
{
if ($mode_balance_ok)
{
- $balancebefore = price2num($balance - ($sign * $objp->amount),'MT');
if ($balancebefore >= 0)
{
print ' '.price($balancebefore).' ';
@@ -1404,14 +1424,14 @@ if ($resql)
if (! empty($arrayfields['b.conciliated']['checked']))
{
- print '';
+ print ' ';
print $objp->conciliated?$langs->trans("Yes"):$langs->trans("No");
print ' ';
if (! $i) $totalarray['nbfield']++;
}
// Action edit/delete
- print '';
+ print ' ';
// Transaction reconciliated or edit link
if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
{
@@ -1510,6 +1530,6 @@ if ($_POST["action"] == "search" && ! $num)
print ''.$langs->trans("NoRecordFound").'
';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/bilan.php b/htdocs/compta/bank/bilan.php
index 5e5194d55c8..99856a2dea2 100644
--- a/htdocs/compta/bank/bilan.php
+++ b/htdocs/compta/bank/bilan.php
@@ -22,7 +22,7 @@
* \brief Page de bilan
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
@@ -92,5 +92,6 @@ print " ".$langs->trans("BankBalance")." ";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php
index 280cd9bdbc0..ccec902bf7c 100644
--- a/htdocs/compta/bank/budget.php
+++ b/htdocs/compta/bank/budget.php
@@ -24,7 +24,7 @@
* \brief Page de budget
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
@@ -96,5 +96,6 @@ else
}
print "";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index db497733863..b58619b66a2 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -6,6 +6,7 @@
* Copyright (C) 2014-2017 Alexandre Spangaro
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2016 Marcos García
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,7 +28,7 @@
* \brief Page to create/view a bank account
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
@@ -284,7 +285,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
$form = new Form($db);
$formbank = new FormBank($db);
$formcompany = new FormCompany($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
@@ -431,7 +432,7 @@ if ($action == 'create')
print ''.$langs->trans("Date").' ';
print '';
- $form->select_date('', 're', 0, 0, 0, 'formsoc');
+ print $form->selectDate('', 're', 0, 0, 0, 'formsoc');
print ' ';
print ''.$langs->trans("BalanceMinimalAllowed").' ';
@@ -1034,5 +1035,6 @@ else
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php
index be029fcb2f5..7ef798103d5 100644
--- a/htdocs/compta/bank/categ.php
+++ b/htdocs/compta/bank/categ.php
@@ -26,7 +26,7 @@
* \brief Page ajout de categories bancaires
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
@@ -144,4 +144,6 @@ if ($action != 'edit')
print '';
+// End of page
llxFooter();
+$db->close();
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 7228214e51c..3bd5997506e 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -36,8 +36,19 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Account extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element = 'bank_account';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element = 'bank_account';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'account';
/**
@@ -286,6 +297,7 @@ class Account extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a link between bank line record and its source
*
@@ -298,6 +310,7 @@ class Account extends CommonObject
*/
function add_url_line($line_id, $url_id, $url, $label, $type)
{
+ // phpcs:enable
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
$sql.= "fk_bank";
$sql.= ", url_id";
@@ -325,6 +338,7 @@ class Account extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* TODO Move this into AccountLine
* Return array with links from llx_bank_url
@@ -332,10 +346,11 @@ class Account extends CommonObject
* @param int $fk_bank To search using bank transaction id
* @param int $url_id To search using link to
* @param string $type To search using type
- * @return array|-1 Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error
+ * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error
*/
function get_url($fk_bank='', $url_id='', $type='')
{
+ // phpcs:enable
$lines = array();
// Check parameters
@@ -774,14 +789,16 @@ class Account extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Update BBAN (RIB) account fields
+ * Update BBAN (RIB) account fields
*
- * @param User $user Object user making update
- * @return int <0 if KO, >0 if OK
+ * @param User $user Object user making update
+ * @return int <0 if KO, >0 if OK
*/
function update_bban(User $user = null)
{
+ // phpcs:enable
global $conf,$langs;
// Clean parameters
@@ -943,8 +960,10 @@ class Account extends CommonObject
* Existing categories are left untouch.
*
* @param int[]|int $categories Category or categories IDs
+ * @return void
*/
- public function setCategories($categories) {
+ public function setCategories($categories)
+ {
// Handle single category
if (! is_array($categories)) {
$categories = array($categories);
@@ -1058,6 +1077,7 @@ class Account extends CommonObject
return $this->LibStatut($this->clos,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of given object status
*
@@ -1067,6 +1087,7 @@ class Account extends CommonObject
*/
function LibStatut($statut, $mode = 0)
{
+ // phpcs:enable
global $langs;
$langs->load('banks');
@@ -1095,6 +1116,7 @@ class Account extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi si un compte peut etre supprimer ou non (sans mouvements)
*
@@ -1102,6 +1124,7 @@ class Account extends CommonObject
*/
function can_be_deleted()
{
+ // phpcs:enable
$can_be_deleted=false;
$sql = "SELECT COUNT(rowid) as nb";
@@ -1160,9 +1183,9 @@ class Account extends CommonObject
}
return $solde;
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -1172,6 +1195,7 @@ class Account extends CommonObject
*/
function load_board(User $user, $filteraccountid = 0)
{
+ // phpcs:enable
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -1218,6 +1242,7 @@ class Account extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge indicateurs this->nb de tableau de bord
* @param int $filteraccountid To get info for a particular account id
@@ -1225,6 +1250,7 @@ class Account extends CommonObject
*/
function load_state_board($filteraccountid = 0)
{
+ // phpcs:enable
global $user;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -1301,13 +1327,19 @@ class Account extends CommonObject
*/
function getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0)
{
- global $conf, $langs;
+ global $conf, $langs, $user;
$result='';
$label = '' . $langs->trans("ShowAccount") . ' ';
$label .= '' . $langs->trans('BankAccount') . ': ' . $this->label;
$label .= '' . $langs->trans('AccountNumber') . ': ' . $this->number;
$label .= '' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code;
+
+ if (empty($user->rights->banque->lire) || !empty($user->socid))
+ {
+ $option = 'nolink';
+ }
+
if (! empty($conf->accounting->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@@ -1338,6 +1370,11 @@ class Account extends CommonObject
$linkstart = 'ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '');
@@ -1492,7 +1529,6 @@ class Account extends CommonObject
*/
function info($id)
{
-
}
/**
@@ -1537,7 +1573,6 @@ class Account extends CommonObject
//Get the order the properties are shown
return $fieldarray;
-
}
/**
@@ -1611,7 +1646,6 @@ class Account extends CommonObject
$this->owner_address = 'Owner address';
$this->country_id = 1;
}
-
}
@@ -1620,37 +1654,69 @@ class Account extends CommonObject
*/
class AccountLine extends CommonObject
{
- var $error;
- var $db;
- var $element='bank';
- var $table_element='bank';
- var $picto = 'generic';
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
- var $id;
- var $ref;
- var $datec;
- var $dateo;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='bank';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='bank';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'generic';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string Ref
+ */
+ public $ref;
+
+ public $datec;
+ public $dateo;
/**
* Value date
*/
- var $datev;
- var $amount;
- var $label;
- var $note;
- var $fk_user_author;
- var $fk_user_rappro;
- var $fk_type;
- var $rappro; // Is it conciliated
- var $num_releve; // If conciliated, what is bank statement
- var $num_chq; // Num of cheque
- var $bank_chq; // Bank of cheque
- var $fk_bordereau; // Id of cheque receipt
+ public $datev;
+ public $amount;
- var $fk_account; // Id of bank account
- var $bank_account_label; // Label of bank account
+ /**
+ * @var string bank transaction lines label
+ */
+ public $label;
- public $emetteur;
+ public $note;
+ public $fk_user_author;
+ public $fk_user_rappro;
+ public $fk_type;
+ public $rappro; // Is it conciliated
+ public $num_releve; // If conciliated, what is bank statement
+ public $num_chq; // Num of cheque
+ public $bank_chq; // Bank of cheque
+ public $fk_bordereau; // Id of cheque receipt
+
+ public $fk_account; // Id of bank account
+ public $bank_account_label; // Label of bank account
+
+ public $emetteur;
/**
* Constructor
@@ -1835,6 +1901,7 @@ class AccountLine extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete bank line records
*
@@ -1843,6 +1910,7 @@ class AccountLine extends CommonObject
*/
function delete_urls(User $user = null)
{
+ // phpcs:enable
$nbko=0;
if ($this->rappro)
@@ -1905,15 +1973,17 @@ class AccountLine extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Update conciliation field
+ * Update conciliation field
*
- * @param User $user Objet user making update
- * @param int $cat Category id
- * @return int <0 if KO, >0 if OK
+ * @param User $user Objet user making update
+ * @param int $cat Category id
+ * @return int <0 if KO, >0 if OK
*/
function update_conciliation(User $user, $cat)
{
+ // phpcs:enable
global $conf,$langs;
$this->db->begin();
@@ -1967,6 +2037,7 @@ class AccountLine extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase/decrease value date of a rowid
*
@@ -1976,6 +2047,7 @@ class AccountLine extends CommonObject
*/
function datev_change($rowid,$sign=1)
{
+ // phpcs:enable
$sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
$resql = $this->db->query($sql);
if ($resql)
@@ -2005,6 +2077,7 @@ class AccountLine extends CommonObject
return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase value date of a rowid
*
@@ -2013,9 +2086,11 @@ class AccountLine extends CommonObject
*/
function datev_next($id)
{
+ // phpcs:enable
return $this->datev_change($id,1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Decrease value date of a rowid
*
@@ -2024,10 +2099,12 @@ class AccountLine extends CommonObject
*/
function datev_previous($id)
{
+ // phpcs:enable
return $this->datev_change($id,-1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase/decrease operation date of a rowid
*
@@ -2037,6 +2114,7 @@ class AccountLine extends CommonObject
*/
function dateo_change($rowid,$sign=1)
{
+ // phpcs:enable
$sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
$resql = $this->db->query($sql);
if ($resql)
@@ -2066,6 +2144,7 @@ class AccountLine extends CommonObject
return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase operation date of a rowid
*
@@ -2074,9 +2153,11 @@ class AccountLine extends CommonObject
*/
function dateo_next($id)
{
+ // phpcs:enable
return $this->dateo_change($id,1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Decrease operation date of a rowid
*
@@ -2085,6 +2166,7 @@ class AccountLine extends CommonObject
*/
function dateo_previous($id)
{
+ // phpcs:enable
return $this->dateo_change($id,-1);
}
@@ -2191,6 +2273,7 @@ class AccountLine extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -2200,6 +2283,7 @@ class AccountLine extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
//$langs->load('companies');
/*
@@ -2269,6 +2353,4 @@ class AccountLine extends CommonObject
}
return 0;
}
-
}
-
diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php
index 176fdb626a5..cc291c6be64 100644
--- a/htdocs/compta/bank/class/bankcateg.class.php
+++ b/htdocs/compta/bank/class/bankcateg.class.php
@@ -30,11 +30,21 @@ class BankCateg // extends CommonObject
{
//public $element='bank_categ'; //!< Id that identify managed objects
//public $table_element='bank_categ'; //!< Name of table without prefix where object is stored
- public $picto='generic';
-
- public $id;
- public $label;
-
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto='generic';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string bank categories label
+ */
+ public $label;
+
/**
* Constructor
@@ -205,7 +215,7 @@ class BankCateg // extends CommonObject
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_categorie = ".$this->id;
-
+
$resql = $this->db->query($sql);
if (!$resql)
{
@@ -213,13 +223,13 @@ class BankCateg // extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror();
}
}
-
+
// Delete link between tag and bank lines
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";
$sql.= " WHERE fk_categ = ".$this->id;
-
+
$resql = $this->db->query($sql);
if (!$resql)
{
@@ -227,21 +237,21 @@ class BankCateg // extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror();
}
}
-
+
// Delete bank categ
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
$sql .= " WHERE rowid=".$this->id;
-
+
$resql = $this->db->query($sql);
- if (!$resql)
+ if (!$resql)
{
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
-
+
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
@@ -339,5 +349,4 @@ class BankCateg // extends CommonObject
$this->id = 0;
$this->label = '';
}
-
}
diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php
index fe56ea99504..25a5b06df98 100644
--- a/htdocs/compta/bank/class/paymentvarious.class.php
+++ b/htdocs/compta/bank/class/paymentvarious.class.php
@@ -30,25 +30,49 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class PaymentVarious extends CommonObject
{
- public $element='variouspayment'; //!< Id that identify managed objects
- public $table_element='payment_various'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='variouspayment';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='payment_various';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'bill';
- var $id;
- var $ref;
- var $tms;
- var $datep;
- var $datev;
- var $sens;
- var $amount;
- var $type_payment;
- var $num_payment;
- var $label;
- var $accountancy_code;
- var $fk_project;
- var $fk_bank;
- var $fk_user_author;
- var $fk_user_modif;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string Ref
+ */
+ public $ref;
+
+ public $tms;
+ public $datep;
+ public $datev;
+ public $sens;
+ public $amount;
+ public $type_payment;
+ public $num_payment;
+
+ /**
+ * @var string various payments label
+ */
+ public $label;
+
+ public $accountancy_code;
+ public $fk_project;
+ public $fk_bank;
+ public $fk_user_author;
+ public $fk_user_modif;
/**
@@ -61,14 +85,13 @@ class PaymentVarious extends CommonObject
$this->db = $db;
$this->element = 'payment_various';
$this->table_element = 'payment_various';
- return 1;
}
/**
* Update database
*
* @param User $user User that modify
- * @param int $notrigger 0=no, 1=yes (no update trigger)
+ * @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
@@ -363,13 +386,14 @@ class PaymentVarious extends CommonObject
// Insert payment into llx_bank
// Add link 'payment_various' in bank_url between payment and bank transaction
- if ($this->sens == '0') $sign='-';
+ $sign=1;
+ if ($this->sens == '0') $sign=-1;
$bank_line_id = $acc->addline(
$this->datep,
$this->type_payment,
$this->label,
- $sign.abs($this->amount),
+ $sign * abs($this->amount),
$this->num_payment,
'',
$user
@@ -434,6 +458,7 @@ class PaymentVarious extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update link between payment various and line generate into llx_bank
*
@@ -442,6 +467,7 @@ class PaymentVarious extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -468,6 +494,7 @@ class PaymentVarious extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -477,35 +504,36 @@ class PaymentVarious extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
@@ -517,11 +545,13 @@ class PaymentVarious extends CommonObject
/**
* Send name clicable (with possibly the picto)
*
- * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
- * @param string $option link option
- * @return string Chaine with URL
+ * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
+ * @param string $option link option
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @param int $notooltip 1=Disable tooltip
+ * @return string String with URL
*/
- function getNomUrl($withpicto=0,$option='')
+ function getNomUrl($withpicto=0, $option='', $save_lastsearch_value=-1, $notooltip=0)
{
global $langs;
@@ -532,8 +562,8 @@ class PaymentVarious extends CommonObject
$linkend=' ';
$result .= $linkstart;
- if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
- if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref);
+ if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+ if ($withpicto != 2) $result.= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '');
$result .= $linkend;
return $result;
@@ -582,5 +612,4 @@ class PaymentVarious extends CommonObject
dol_print_error($this->db);
}
}
-
}
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index 33e74dc3691..f908b68b35c 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -24,7 +24,7 @@
* \ingroup banque
* \brief Page de gestion des documents attaches a un compte bancaire
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php";
@@ -105,7 +105,7 @@ if ($id > 0 || !empty($ref)) {
dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account');
- // Construit liste des fichiers
+ // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$',
$sortfield,
(strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
@@ -147,7 +147,6 @@ else {
exit;
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php
index b829002a990..7dad720139a 100644
--- a/htdocs/compta/bank/graph.php
+++ b/htdocs/compta/bank/graph.php
@@ -23,7 +23,7 @@
* \brief Page graph des transactions bancaires
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@@ -864,7 +864,6 @@ if ($mode == 'showalltime')
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php
index ab43b9374aa..7eaeb515aa9 100644
--- a/htdocs/compta/bank/info.php
+++ b/htdocs/compta/bank/info.php
@@ -21,7 +21,7 @@
* \brief Onglet info d'une ecriture bancaire
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -71,5 +71,6 @@ print ' ';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php
index e006f78c6e7..85cd839fd44 100644
--- a/htdocs/compta/bank/ligne.php
+++ b/htdocs/compta/bank/ligne.php
@@ -7,6 +7,7 @@
* Copyright (C) 2015-2017 Alexandre Spangaro
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2016 Marcos García
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,12 +29,12 @@
* \brief Page to edit a bank transaction record
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'compta', 'bills'));
+$langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
if (! empty($conf->adherent->enabled)) $langs->load("members");
if (! empty($conf->don->enabled)) $langs->load("donations");
if (! empty($conf->loan->enabled)) $langs->load("loan");
@@ -98,8 +99,10 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban
{
dol_print_error($db);
}
- } else {
- setEventMessage('Missing ids','errors');
+ }
+ else
+ {
+ setEventMessages($langs->trans("MissingIds"), null, 'errors');
}
}
@@ -495,7 +498,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print '';
- print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro);
+ print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro);
if (! $objp->rappro)
{
print ' ';
@@ -519,7 +522,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print ' ';
- print $form->select_date($db->jdate($objp->dv),'datev','','','','update',1,0,1,$objp->rappro);
+ print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro);
if (! $objp->rappro)
{
print ' ';
@@ -686,6 +689,6 @@ if ($result)
}
else dol_print_error($db);
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index e52e285742c..1f01355050c 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -27,7 +27,7 @@ use Stripe\BankAccount;
* \brief Home page of bank module
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
@@ -604,7 +604,6 @@ print "";
print "";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index 1d9d5526700..3f1bede8e20 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -25,7 +25,7 @@
* \brief Page to show a bank statement report
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
@@ -813,7 +813,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php
index 765001e75a5..38109b964b4 100644
--- a/htdocs/compta/bank/transfer.php
+++ b/htdocs/compta/bank/transfer.php
@@ -5,6 +5,7 @@
* Copyright (C) 2012 Juanjo Menent
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Marcos García
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,7 +27,7 @@
* \brief Page de saisie d'un virement
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -253,7 +254,7 @@ $form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->mult
print " \n";
print "";
-$form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
+print $form->selectDate((! empty($dateo)?$dateo:''), '', '', '', '', 'add');
print " \n";
print ' ';
print ' ';
@@ -265,5 +266,6 @@ print '";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php
index 0fb8880ce87..2389d1fec77 100644
--- a/htdocs/compta/bank/treso.php
+++ b/htdocs/compta/bank/treso.php
@@ -330,5 +330,6 @@ else
print $langs->trans("ErrorBankAccountNotFound");
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 1b4d7579892..33757c67c6a 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2017 Alexandre Spangaro
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -220,7 +221,7 @@ if (empty($reshook))
llxHeader("",$langs->trans("VariousPayment"));
$form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
if ($id)
@@ -255,13 +256,13 @@ if ($action == 'create')
// Date payment
print '';
print fieldLabel('DatePayment','datep',1).' ';
- print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
+ print $form->selectDate((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
print ' ';
// Date value for bank
print '';
print fieldLabel('DateValue','datev',0).' ';
- print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
+ print $form->selectDate((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
print ' ';
// Label
@@ -499,8 +500,6 @@ if ($id)
print " ";
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php
index cf596860a4b..faa9a8ed199 100644
--- a/htdocs/compta/bank/various_payment/document.php
+++ b/htdocs/compta/bank/various_payment/document.php
@@ -124,7 +124,7 @@ if ($object->id)
print '';
print '
';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -154,6 +154,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php
index 6535e0c0082..7e3f921b67f 100644
--- a/htdocs/compta/bank/various_payment/index.php
+++ b/htdocs/compta/bank/various_payment/index.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2017 Laurent Destailleur
+/* Copyright (C) 2017 Alexandre Spangaro
+ * Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -189,7 +190,7 @@ if ($result)
// Date
print '';
print '';
- print $form->select_date($search_date, 'date_doc', 0, 0, 1);
+ print $form->selectDate($search_date, 'date_doc', 0, 0, 1);
print '
';
print ' ';
@@ -344,5 +345,6 @@ else
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php
index bb66871d6c0..c39a6379000 100644
--- a/htdocs/compta/bank/various_payment/info.php
+++ b/htdocs/compta/bank/various_payment/info.php
@@ -58,6 +58,6 @@ print ' ';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index 6d369b696b9..e367054fc40 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -455,7 +455,7 @@ while($j<$numlt)
// Payment Salary
-if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
+if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
{
if (! $mode || $mode != 'sconly')
{
@@ -568,7 +568,6 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php
index 05d509e268d..861ee6e897f 100644
--- a/htdocs/compta/deplacement/card.php
+++ b/htdocs/compta/deplacement/card.php
@@ -3,7 +3,8 @@
* Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2012 Juanjo Menent
- * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,8 +21,8 @@
*/
/**
- * \file htdocs/compta/deplacement/card.php
- * \brief Page to show a trip card
+ * \file htdocs/compta/deplacement/card.php
+ * \brief Page to show a trip card
*/
require '../../main.inc.php';
@@ -263,7 +264,7 @@ if ($action == 'create')
print "";
print ''.$langs->trans("Date").' ';
- print $form->select_date($datec?$datec:-1,'','','','','add',1,1,1);
+ print $form->selectDate($datec?$datec:-1, '', '', '', '', 'add', 1, 1);
print ' ';
// Km
@@ -360,7 +361,7 @@ else if ($id)
// Date
print ''.$langs->trans("Date").' ';
- print $form->select_date($object->date,'',0,0,0,'update',1,0,1);
+ print $form->selectDate($object->date, '', 0, 0, 0, 'update', 1, 0);
print ' ';
// Km
@@ -577,7 +578,6 @@ else if ($id)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php
index 05664080ed3..403988052bd 100644
--- a/htdocs/compta/deplacement/class/deplacement.class.php
+++ b/htdocs/compta/deplacement/class/deplacement.class.php
@@ -31,23 +31,44 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Deplacement extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='deplacement';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='deplacement';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line = '';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element = '';
+
public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- var $datec; // Creation date
- var $dated;
- var $fk_user_author;
- var $fk_user;
- var $km;
- var $socid;
- var $statut; // 0=draft, 1=validated
- var $extraparams=array();
+ public $datec; // Creation date
+ public $dated;
+ public $fk_user_author;
- var $statuts=array();
- var $statuts_short=array();
+ /**
+ * @var int User ID
+ */
+ public $fk_user;
+
+ public $km;
+ public $socid;
+ public $statut; // 0=draft, 1=validated
+ public $extraparams=array();
+
+ public $statuts=array();
+ public $statuts_short=array();
/**
* Constructor
@@ -146,7 +167,6 @@ class Deplacement extends CommonObject
$this->db->rollback();
return -1;
}
-
}
/**
@@ -293,6 +313,7 @@ class Deplacement extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -302,35 +323,36 @@ class Deplacement extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
@@ -445,6 +467,4 @@ class Deplacement extends CommonObject
dol_print_error($this->db);
}
}
-
}
-
diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php
index 75ac39a7cca..e490c90f1ed 100644
--- a/htdocs/compta/deplacement/class/deplacementstats.class.php
+++ b/htdocs/compta/deplacement/class/deplacementstats.class.php
@@ -30,6 +30,9 @@ include_once DOL_DOCUMENT_ROOT . '/compta/deplacement/class/deplacement.class.ph
*/
class DeplacementStats extends Stats
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element;
var $socid;
diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php
index 59d92140c86..e34a2aedb21 100644
--- a/htdocs/compta/deplacement/document.php
+++ b/htdocs/compta/deplacement/document.php
@@ -91,7 +91,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -129,6 +129,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php
index a390023e280..98c939965a3 100644
--- a/htdocs/compta/deplacement/index.php
+++ b/htdocs/compta/deplacement/index.php
@@ -204,7 +204,6 @@ else dol_print_error($db);
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php
index 6a62484323f..f63b1765efb 100644
--- a/htdocs/compta/deplacement/info.php
+++ b/htdocs/compta/deplacement/info.php
@@ -59,5 +59,6 @@ if ($id)
print '';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php
index bdbdad0a712..20d300d9da4 100644
--- a/htdocs/compta/deplacement/list.php
+++ b/htdocs/compta/deplacement/list.php
@@ -212,6 +212,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php
index cf652948a6e..193e2c7e9a9 100644
--- a/htdocs/compta/deplacement/stats/index.php
+++ b/htdocs/compta/deplacement/stats/index.php
@@ -312,7 +312,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php
index 2c676e399de..1fe26e82a54 100644
--- a/htdocs/compta/facture/admin/facture_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php
@@ -80,7 +80,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -93,7 +93,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -114,6 +114,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
index 18aa3c99442..23c0d79a33c 100644
--- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -115,6 +115,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
index 2b90ae7fe05..0947f788719 100644
--- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
index 97f8b78b195..46d9ed28335 100644
--- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
@@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 68a24a20933..a40ad636976 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1,19 +1,20 @@
- * Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2015 Regis Houssin
- * Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2010-2015 Juanjo Menent
- * Copyright (C) 2012-2013 Christophe Battarel
- * Copyright (C) 2012-2013 Cédric Salvador
- * Copyright (C) 2012-2014 Raphaël Doursenaud
- * Copyright (C) 2013 Jean-Francois FERRY
- * Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2013 Cédric Salvador
- * Copyright (C) 2014-2018 Ferran Marcet
- * Copyright (C) 2015-2016 Marcos García
+/* Copyright (C) 2002-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2015 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2010-2015 Juanjo Menent
+ * Copyright (C) 2012-2013 Christophe Battarel
+ * Copyright (C) 2012-2013 Cédric Salvador
+ * Copyright (C) 2012-2014 Raphaël Doursenaud
+ * Copyright (C) 2013 Jean-Francois FERRY
+ * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2014-2018 Ferran Marcet
+ * Copyright (C) 2015-2016 Marcos García
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -513,7 +514,7 @@ if (empty($reshook))
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
{
if (! $idwarehouse || $idwarehouse == - 1) {
- $error ++;
+ $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action = '';
}
@@ -573,7 +574,7 @@ if (empty($reshook))
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
{
if (! $idwarehouse || $idwarehouse == - 1) {
- $error ++;
+ $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action = '';
}
@@ -832,7 +833,7 @@ if (empty($reshook))
}
if (! ($_POST['fac_replacement'] > 0)) {
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors');
}
@@ -878,14 +879,14 @@ if (empty($reshook))
$sourceinvoice = GETPOST('fac_avoir');
if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
{
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors');
}
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($dateinvoice))
{
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
}
@@ -1109,7 +1110,7 @@ if (empty($reshook))
{
if (GETPOST('socid', 'int') < 1)
{
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors');
}
@@ -1279,7 +1280,7 @@ if (empty($reshook))
}
} else {
setEventMessages($srcobject->error, $srcobject->errors, 'errors');
- $error ++;
+ $error++;
}
}
@@ -1290,7 +1291,7 @@ if (empty($reshook))
{
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
$descline = $langs->trans('Deposit');
- $descline.= ' - '.$langs->trans($arraylist[$typeamount]);
+ //$descline.= ' - '.$langs->trans($arraylist[$typeamount]);
if ($typeamount=='amount') {
$descline.= ' ('. price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')';
} elseif ($typeamount=='variable') {
@@ -1373,7 +1374,7 @@ if (empty($reshook))
$result = $object->insert_discount($discountid); // This include link_to_invoice
} else {
setEventMessages($discount->error, $discount->errors, 'errors');
- $error ++;
+ $error++;
break;
}
} else {
@@ -1429,7 +1430,7 @@ if (empty($reshook))
$lineid = $result;
} else {
$lineid = 0;
- $error ++;
+ $error++;
break;
}
@@ -1441,7 +1442,7 @@ if (empty($reshook))
}
} else {
setEventMessages($srcobject->error, $srcobject->errors, 'errors');
- $error ++;
+ $error++;
}
}
@@ -1665,37 +1666,46 @@ if (empty($reshook))
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
- $error ++;
+ $error++;
}
if (!$prod_entry_mode)
{
if (GETPOST('type') < 0 && ! GETPOST('search_idprod'))
{
setEventMessages($langs->trans('ErrorChooseBetweenFreeEntryOrPredefinedProduct'), null, 'errors');
- $error ++;
+ $error++;
}
}
if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
- $error ++;
+ $error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not ''
{
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
- $error ++;
+ if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
+ else
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
}
if ($qty == '') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
- $error ++;
+ $error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
- $error ++;
+ $error++;
}
if ($qty < 0) {
$langs->load("errors");
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
- $error ++;
+ $error++;
}
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
@@ -1705,9 +1715,11 @@ if (empty($reshook))
if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
$idprod = $res->fk_product_child;
- } else {
- setEventMessage($langs->trans('ErrorProductCombinationNotFound'), 'errors');
- $error ++;
+ }
+ else
+ {
+ setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors');
+ $error++;
}
}
}
@@ -2113,7 +2125,7 @@ if (empty($reshook))
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
- $error ++;
+ $error++;
}
} else {
$type = GETPOST('type');
@@ -2122,14 +2134,29 @@ if (empty($reshook))
// Check parameters
if (GETPOST('type') < 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
- $error ++;
+ $error++;
}
}
if ($qty < 0) {
$langs->load("errors");
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
- $error ++;
+ $error++;
}
+ if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') // Unit price can be 0 but not ''
+ {
+ if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
+ else
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
+ }
+
// Update line
if (! $error) {
@@ -2430,7 +2457,7 @@ if (empty($reshook))
if($error)
{
- setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors');
+ setEventMessages($langs->trans('ErrorsOnXLines',$error), null, 'errors');
}
}
}
@@ -2873,7 +2900,7 @@ if ($action == 'create')
if (($origin == 'propal') || ($origin == 'commande'))
{
print '';
- $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
+ $arraylist = array('amount' => $langs->transnoentitiesnoconv('FixAmount'), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')));
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
print ' ';
print '' . $langs->trans('Value') . ': ';
@@ -3046,7 +3073,7 @@ if ($action == 'create')
// Date invoice
print ' ' . $langs->trans('DateInvoice') . ' ';
- print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1);
+ print $form->selectDate($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1);
print ' ';
// Date point of tax
@@ -3054,7 +3081,7 @@ if ($action == 'create')
{
print '' . $langs->trans('DatePointOfTax') . ' ';
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
- print $form->select_date($date_pointoftax?$date_pointoftax:-1, 'date_pointoftax', '', '', '', "add", 1, 1, 1);
+ print $form->selectDate($date_pointoftax?$date_pointoftax:-1, 'date_pointoftax', '', '', '', "add", 1, 1);
print ' ';
}
@@ -3200,7 +3227,7 @@ if ($action == 'create')
print ' ';
print ' ';
- switch ($classname) {
+ switch (get_class($objectsrc)) {
case 'Propal':
$newclassname = 'CommercialProposal';
break;
@@ -3217,7 +3244,7 @@ if ($action == 'create')
$newclassname = 'Intervention';
break;
default:
- $newclassname = $classname;
+ $newclassname = get_class($objectsrc);
}
print '' . $langs->trans($newclassname) . ' ' . $objectsrc->getNomUrl(1);
@@ -3376,13 +3403,14 @@ else if ($id > 0 || ! empty($ref))
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
$label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
- // 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
- // => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"))));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"), 0, $forcecombo))
+ );
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1);
} else {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1);
@@ -3597,13 +3625,11 @@ else if ($id > 0 || ! empty($ref))
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
- if (! $formconfirm)
- {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
@@ -3702,7 +3728,7 @@ else if ($id > 0 || ! empty($ref))
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(0, $object->id);
if ($result > 0){
- print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(), $discount->getNomUrl(1, 'discount')).' ';
+ print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).' ';
}
}
print ' ';
@@ -4027,8 +4053,6 @@ else if ($id > 0 || ! empty($ref))
print '';
- // List of previous situation invoices
-
$sign = 1;
if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1;
$nbrows = 8;
@@ -4369,7 +4393,7 @@ else if ($id > 0 || ! empty($ref))
}
else // Credit note
{
- $cssforamountpaymentcomplete='';
+ $cssforamountpaymentcomplete='amountpaymentneutral';
// Total already paid back
print '';
@@ -4384,7 +4408,7 @@ else if ($id > 0 || ! empty($ref))
if ($resteapayeraffiche <= 0)
print $langs->trans('RemainderToPayBack');
else
- print $langs->trans('ExcessPaydBack');
+ print $langs->trans('ExcessPaid');
print ' : ';
print '' . price($sign * $resteapayeraffiche) . ' ';
print ' ';
@@ -4632,7 +4656,7 @@ else if ($id > 0 || ! empty($ref))
if ($objectidnext) {
print '' . $langs->trans('DoPayment') . '
';
} else {
- //if ($resteapayer == 0) {
+ //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done)
// print '' . $langs->trans('DoPayment') . '
';
//} else {
print '';
@@ -4729,7 +4753,7 @@ else if ($id > 0 || ! empty($ref))
}
// For situation invoice with excess received
- if ($object->statut == Facture::STATUS_VALIDATED
+ if ($object->statut > Facture::STATUS_DRAFT
&& ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0
&& $user->rights->facture->creer
&& !$objectidnext
@@ -4747,7 +4771,7 @@ else if ($id > 0 || ! empty($ref))
}
// remove situation from cycle
- if ($object->statut == Facture::STATUS_VALIDATED
+ if ($object->statut > Facture::STATUS_DRAFT
&& $object->type == Facture::TYPE_SITUATION
&& $user->rights->facture->creer
&& !$objectidnext
@@ -4883,5 +4907,6 @@ else if ($id > 0 || ! empty($ref))
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 7012b0ef800..5075d9d8cb7 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -32,7 +32,7 @@ class Invoices extends DolibarrApi
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
- 'socid'
+ 'socid',
);
/**
@@ -104,7 +104,8 @@ class Invoices extends DolibarrApi
*
* @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -245,29 +246,30 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function createInvoiceFromOrder($orderid) {
+ function createInvoiceFromOrder($orderid)
+ {
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
if(! DolibarrApiAccess::$user->rights->commande->lire) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($orderid)) {
- throw new RestException(400, 'Order ID is mandatory');
+ throw new RestException(400, 'Order ID is mandatory');
}
$order = new Commande($this->db);
$result = $order->fetch($orderid);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
$result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(405, $this->invoice->error);
+ throw new RestException(405, $this->invoice->error);
}
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
@@ -282,7 +284,8 @@ class Invoices extends DolibarrApi
*
* @return int
*/
- function getLines($id) {
+ function getLines($id)
+ {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401);
}
@@ -319,7 +322,8 @@ class Invoices extends DolibarrApi
* @throws 401
* @throws 404
*/
- function putLine($id, $lineid, $request_data = null) {
+ function putLine($id, $lineid, $request_data = null)
+ {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
@@ -383,7 +387,8 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function deleteLine($id, $lineid) {
+ function deleteLine($id, $lineid)
+ {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
@@ -511,67 +516,68 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 400
*/
- function postLine($id, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
- }
+ function postLine($id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->facture->creer) {
+ throw new RestException(401);
+ }
- $result = $this->invoice->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
- }
+ $result = $this->invoice->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Invoice not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- $request_data = (object) $request_data;
+ $request_data = (object) $request_data;
- // Reset fk_parent_line for no child products and special product
- if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
- $request_data->fk_parent_line = 0;
- }
+ // Reset fk_parent_line for no child products and special product
+ if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
+ $request_data->fk_parent_line = 0;
+ }
- // calculate pa_ht
- $marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht);
- $pa_ht = $marginInfos[0];
+ // calculate pa_ht
+ $marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht);
+ $pa_ht = $marginInfos[0];
- $updateRes = $this->invoice->addline(
- $request_data->desc,
- $request_data->subprice,
- $request_data->qty,
- $request_data->tva_tx,
- $request_data->localtax1_tx,
- $request_data->localtax2_tx,
- $request_data->fk_product,
- $request_data->remise_percent,
- $request_data->date_start,
- $request_data->date_end,
- $request_data->fk_code_ventilation,
- $request_data->info_bits,
- $request_data->fk_remise_except,
- 'HT',
- 0,
- $request_data->product_type,
- $request_data->rang,
- $request_data->special_code,
- $request_data->origin,
- $request_data->origin_id,
- $request_data->fk_parent_line,
- empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice,
- $pa_ht,
- $request_data->label,
- $request_data->array_options,
- $request_data->situation_percent,
- $request_data->fk_prev_id,
- $request_data->fk_unit
- );
+ $updateRes = $this->invoice->addline(
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ $request_data->fk_product,
+ $request_data->remise_percent,
+ $request_data->date_start,
+ $request_data->date_end,
+ $request_data->fk_code_ventilation,
+ $request_data->info_bits,
+ $request_data->fk_remise_except,
+ 'HT',
+ 0,
+ $request_data->product_type,
+ $request_data->rang,
+ $request_data->special_code,
+ $request_data->origin,
+ $request_data->origin_id,
+ $request_data->fk_parent_line,
+ empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice,
+ $pa_ht,
+ $request_data->label,
+ $request_data->array_options,
+ $request_data->situation_percent,
+ $request_data->fk_prev_id,
+ $request_data->fk_unit
+ );
- if ($updateRes < 0) {
+ if ($updateRes < 0) {
throw new RestException(400, 'Unable to insert the new line. Check your inputs. '.$this->invoice->error);
- }
+ }
- return $updateRes;
+ return $updateRes;
}
/**
@@ -647,23 +653,23 @@ class Invoices extends DolibarrApi
function settodraft($id, $idwarehouse=-1)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_draft(DolibarrApiAccess::$user, $idwarehouse);
if ($result == 0) {
- throw new RestException(304, 'Nothing done.');
+ throw new RestException(304, 'Nothing done.');
}
if ($result < 0) {
- throw new RestException(500, 'Error : '.$this->invoice->error);
+ throw new RestException(500, 'Error : '.$this->invoice->error);
}
$result = $this->invoice->fetch($id);
@@ -750,23 +756,23 @@ class Invoices extends DolibarrApi
function settopaid($id, $close_code='', $close_note='')
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note);
if ($result == 0) {
- throw new RestException(304, 'Error nothing done. May be object is already validated');
+ throw new RestException(304, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
- throw new RestException(500, 'Error : '.$this->invoice->error);
+ throw new RestException(500, 'Error : '.$this->invoice->error);
}
@@ -801,23 +807,23 @@ class Invoices extends DolibarrApi
function settounpaid($id)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_unpaid(DolibarrApiAccess::$user);
if ($result == 0) {
- throw new RestException(304, 'Nothing done');
+ throw new RestException(304, 'Nothing done');
}
if ($result < 0) {
- throw new RestException(500, 'Error : '.$this->invoice->error);
+ throw new RestException(500, 'Error : '.$this->invoice->error);
}
@@ -849,30 +855,31 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function useDiscount($id, $discountid) {
+ function useDiscount($id, $discountid)
+ {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Invoice ID is mandatory');
+ throw new RestException(400, 'Invoice ID is mandatory');
}
if(empty($discountid)) {
- throw new RestException(400, 'Discount ID is mandatory');
+ throw new RestException(400, 'Discount ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->insert_discount($discountid);
if( $result < 0) {
- throw new RestException(405, $this->invoice->error);
+ throw new RestException(405, $this->invoice->error);
}
return $result;
@@ -894,32 +901,33 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function useCreditNote($id, $discountid) {
+ function useCreditNote($id, $discountid)
+ {
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Invoice ID is mandatory');
+ throw new RestException(400, 'Invoice ID is mandatory');
}
if(empty($discountid)) {
- throw new RestException(400, 'Credit ID is mandatory');
+ throw new RestException(400, 'Credit ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$discount = new DiscountAbsolute($this->db);
$result = $discount->fetch($discountid);
if( ! $result ) {
- throw new RestException(404, 'Credit not found');
+ throw new RestException(404, 'Credit not found');
}
$result = $discount->link_to_invoice(0, $id);
if( $result < 0) {
- throw new RestException(405, $discount->error);
+ throw new RestException(405, $discount->error);
}
return $result;
@@ -938,27 +946,28 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function getPayments($id) {
+ function getPayments($id)
+ {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Invoice ID is mandatory');
+ throw new RestException(400, 'Invoice ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->getListOfPayments();
if( $result < 0) {
- throw new RestException(405, $this->invoice->error);
+ throw new RestException(405, $this->invoice->error);
}
return $result;
@@ -985,8 +994,9 @@ class Invoices extends DolibarrApi
* @throws 401
* @throws 404
*/
- function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') {
- global $conf;
+ function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='')
+ {
+ global $conf;
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
@@ -1111,7 +1121,7 @@ class Invoices extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(403);
+ throw new RestException(403);
}
foreach($arrayofamounts as $id => $amount) {
if(empty($id)) {
@@ -1215,18 +1225,19 @@ class Invoices extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
- $object = parent::_cleanObjectDatas($object);
+ $object = parent::_cleanObjectDatas($object);
unset($object->note);
- unset($object->address);
- unset($object->barcode_type);
- unset($object->barcode_type_code);
- unset($object->barcode_type_label);
- unset($object->barcode_type_coder);
+ unset($object->address);
+ unset($object->barcode_type);
+ unset($object->barcode_type_code);
+ unset($object->barcode_type_label);
+ unset($object->barcode_type_coder);
- return $object;
+ return $object;
}
/**
@@ -1241,11 +1252,11 @@ class Invoices extends DolibarrApi
{
$invoice = array();
foreach (Invoices::$FIELDS as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$invoice[$field] = $data[$field];
}
return $invoice;
}
-
}
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 71123d1c6e2..1c97b82d926 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -39,36 +39,55 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
*/
class FactureRec extends CommonInvoice
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='facturerec';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='facture_rec';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line='facturedet_rec';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element='fk_facture';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='bill';
- var $entity;
- var $number;
- var $date;
- var $amount;
- var $remise;
- var $tva;
- var $total;
- var $db_table;
- var $propalid;
+ public $entity;
+ public $number;
+ public $date;
+ public $amount;
+ public $remise;
+ public $tva;
+ public $total;
+ public $db_table;
+ public $propalid;
- var $date_last_gen;
- var $date_when;
- var $nb_gen_done;
- var $nb_gen_max;
+ public $date_last_gen;
+ public $date_when;
+ public $nb_gen_done;
+ public $nb_gen_max;
- var $frequency;
- var $unit_frequency;
+ public $frequency;
+ public $unit_frequency;
- var $rang;
- var $special_code;
+ public $rang;
+ public $special_code;
- var $usenewprice=0;
+ public $usenewprice=0;
- var $suspended; // status
+ public $suspended; // status
const STATUS_NOTSUSPENDED = 0;
const STATUS_SUSPENDED = 1;
@@ -432,18 +451,20 @@ class FactureRec extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Recupere les lignes de factures predefinies dans this->lines
*
- * @return int 1 if OK, < 0 if KO
- */
+ * @return int 1 if OK, < 0 if KO
+ */
function fetch_lines()
{
+ // phpcs:enable
$this->lines=array();
// Retreive all extrafield for line
// fetch optionals attributes and labels
- require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
$extrafieldsline=$extrafieldsline->fetch_name_optionals_label('facturedet_rec',true);
@@ -983,7 +1004,8 @@ class FactureRec extends CommonInvoice
$error=0;
- $langs->load("bills");
+ // Load translation files required by the page
+ $langs->loadLangs(array("main","bills"));
$nb_create=0;
@@ -1060,6 +1082,8 @@ class FactureRec extends CommonInvoice
}
if (! $error && $facturerec->generate_pdf)
{
+ // We refresh the object in order to have all necessary data (like date_lim_reglement)
+ $facture->fetch($facture->id);
$result = $facture->generateDocument($facturerec->modelpdf, $langs);
if ($result <= 0)
{
@@ -1170,6 +1194,7 @@ class FactureRec extends CommonInvoice
return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a status
*
@@ -1182,6 +1207,7 @@ class FactureRec extends CommonInvoice
*/
function LibStatut($recur, $status, $mode=0, $alreadypaid=-1, $type=0)
{
+ // phpcs:enable
global $langs;
$langs->load('bills');
@@ -1200,7 +1226,7 @@ class FactureRec extends CommonInvoice
else return $langs->trans("Draft");
}
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
$prefix='Short';
if ($recur)
@@ -1214,7 +1240,7 @@ class FactureRec extends CommonInvoice
else return $langs->trans("Draft");
}
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($recur)
{
@@ -1227,7 +1253,7 @@ class FactureRec extends CommonInvoice
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
}
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($recur)
{
@@ -1241,7 +1267,7 @@ class FactureRec extends CommonInvoice
else return img_picto($langs->trans('Draft'),'statut0');
}
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
$prefix='';
if ($recur)
@@ -1255,7 +1281,7 @@ class FactureRec extends CommonInvoice
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
}
}
- if ($mode == 5 || $mode == 6)
+ elseif ($mode == 5 || $mode == 6)
{
$prefix='';
if ($mode == 5) $prefix='Short';
@@ -1636,7 +1662,14 @@ class FactureRec extends CommonInvoice
*/
class FactureLigneRec extends CommonInvoiceLine
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='facturedetrec';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='facturedet_rec';
var $date_start_fill;
@@ -1840,7 +1873,5 @@ class FactureLigneRec extends CommonInvoiceLine
$this->db->rollback();
return -2;
}
-
}
-
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index b7d86cf630a..0773e6eedc1 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -53,16 +53,37 @@ if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accoun
*/
class Facture extends CommonInvoice
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='facture';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='facture';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line = 'facturedet';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element = 'fk_facture';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='bill';
+
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
@@ -112,14 +133,17 @@ class Facture extends CommonInvoice
public $cond_reglement_code; // Code in llx_c_paiement
public $mode_reglement_code; // Code in llx_c_paiement
public $fk_bank; // Field to store bank id to use when payment mode is withdraw
+
/**
* @deprecated
*/
public $products=array();
+
/**
* @var FactureLigne[]
*/
public $lines=array();
+
public $line;
public $extraparams=array();
public $specimen;
@@ -1159,7 +1183,8 @@ class Facture extends CommonInvoice
if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id;
else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id;
- if ($short) return $url;
+ if (!$user->rights->facture->lire)
+ $option = 'nolink';
if ($option !== 'nolink')
{
@@ -1169,6 +1194,8 @@ class Facture extends CommonInvoice
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
+ if ($short) return $url;
+
$picto='bill';
if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
@@ -1185,9 +1212,9 @@ class Facture extends CommonInvoice
$label.= '' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_tva))
$label.= '' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
- if (! empty($this->total_localtax1))
- $label.= '' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency);
- if (! empty($this->total_localtax2))
+ if (! empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000'
+ $label.= 'eee' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency);
+ if (! empty($this->total_localtax2) && $this->total_localtax2 != 0)
$label.= '' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_ttc))
$label.= '' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
@@ -1214,6 +1241,11 @@ class Facture extends CommonInvoice
$linkstart.=$linkclose.'>';
$linkend='';
+ if ($option == 'nolink') {
+ $linkstart = '';
+ $linkend = '';
+ }
+
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref);
@@ -1274,8 +1306,10 @@ class Facture extends CommonInvoice
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
- $sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
- if ($rowid) $sql.= " AND f.rowid=".$rowid;
+
+ if ($rowid) $sql.= " WHERE f.rowid=".$rowid;
+ else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid
+
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'";
@@ -1390,6 +1424,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load all detailed lines into this->lines
*
@@ -1397,6 +1432,7 @@ class Facture extends CommonInvoice
*/
function fetch_lines()
{
+ // phpcs:enable
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
@@ -1535,7 +1571,6 @@ class Facture extends CommonInvoice
}
}
}
-
}
/**
@@ -1547,6 +1582,8 @@ class Facture extends CommonInvoice
*/
function update(User $user, $notrigger=0)
{
+ global $conf;
+
$error=0;
// Clean parameters
@@ -1612,17 +1649,23 @@ class Facture extends CommonInvoice
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
- if (! $notrigger)
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- // Call trigger
- $result=$this->call_trigger('BILL_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
+ $error++;
}
}
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('BILL_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
// Commit or rollback
if ($error)
{
@@ -1642,6 +1685,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount)
*
@@ -1650,6 +1694,7 @@ class Facture extends CommonInvoice
*/
function insert_discount($idremise)
{
+ // phpcs:enable
global $langs;
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@@ -1742,6 +1787,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set customer ref
*
@@ -1751,6 +1797,7 @@ class Facture extends CommonInvoice
*/
function set_ref_client($ref_client, $notrigger=0)
{
+ // phpcs:enable
global $user;
$error=0;
@@ -1975,6 +2022,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1
* ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0
@@ -1986,6 +2034,7 @@ class Facture extends CommonInvoice
*/
function set_paid($user, $close_code='', $close_note='')
{
+ // phpcs:enable
$error=0;
if ($this->paye != 1)
@@ -2033,6 +2082,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag la facture comme non payee completement + appel trigger BILL_UNPAYED
* Fonction utilisee quand un paiement prelevement est refuse,
@@ -2043,6 +2093,7 @@ class Facture extends CommonInvoice
*/
function set_unpaid($user)
{
+ // phpcs:enable
$error=0;
$this->db->begin();
@@ -2080,6 +2131,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL
* Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because
@@ -2092,6 +2144,7 @@ class Facture extends CommonInvoice
*/
function set_canceled($user, $close_code='', $close_note='')
{
+ // phpcs:enable
dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG);
@@ -2443,6 +2496,7 @@ class Facture extends CommonInvoice
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set draft status
*
@@ -2452,6 +2506,7 @@ class Facture extends CommonInvoice
*/
function set_draft($user,$idwarehouse=-1)
{
+ // phpcs:enable
global $conf,$langs;
$error=0;
@@ -3008,6 +3063,7 @@ class Facture extends CommonInvoice
else return $situation_percent < $obj->situation_percent;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update invoice line with percentage
*
@@ -3017,9 +3073,10 @@ class Facture extends CommonInvoice
*/
function update_percent($line, $percent)
{
+ // phpcs:enable
global $mysoc,$user;
- include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php');
+ include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
// Cap percentages to 100
if ($percent > 100) $percent = 100;
@@ -3104,6 +3161,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set percent discount
*
@@ -3114,6 +3172,7 @@ class Facture extends CommonInvoice
*/
function set_remise($user, $remise, $notrigger=0)
{
+ // phpcs:enable
// Clean parameters
if (empty($remise)) $remise=0;
@@ -3168,6 +3227,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set absolute discount
*
@@ -3178,6 +3238,7 @@ class Facture extends CommonInvoice
*/
function set_remise_absolue($user, $remise, $notrigger=0)
{
+ // phpcs:enable
if (empty($remise)) $remise=0;
if ($user->rights->facture->creer)
@@ -3368,6 +3429,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of invoices (eventually filtered on a user) into an array
*
@@ -3383,6 +3445,7 @@ class Facture extends CommonInvoice
*/
function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='f.datef,f.rowid', $sortorder='DESC')
{
+ // phpcs:enable
global $conf,$user;
$ga = array();
@@ -3442,6 +3505,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of invoices qualified to be replaced by another invoice.
* Invoices matching the following rules are returned:
@@ -3452,6 +3516,7 @@ class Facture extends CommonInvoice
*/
function list_replacable_invoices($socid=0)
{
+ // phpcs:enable
global $conf;
$return = array();
@@ -3490,6 +3555,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of invoices qualified to be corrected by a credit note.
* Invoices matching the following rules are returned:
@@ -3500,6 +3566,7 @@ class Facture extends CommonInvoice
*/
function list_qualified_avoir_invoices($socid=0)
{
+ // phpcs:enable
global $conf;
$return = array();
@@ -3563,6 +3630,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Create a withdrawal request for a standing order.
* Use the remain to pay excluding all existing open direct debit requests.
@@ -3573,6 +3641,7 @@ class Facture extends CommonInvoice
*/
function demande_prelevement($fuser, $amount=0)
{
+ // phpcs:enable
$error=0;
@@ -3673,6 +3742,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Supprime une demande de prelevement
*
@@ -3682,6 +3752,7 @@ class Facture extends CommonInvoice
*/
function demande_prelevement_delete($fuser, $did)
{
+ // phpcs:enable
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ' WHERE rowid = '.$did;
$sql .= ' AND traite = 0';
@@ -3698,6 +3769,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -3706,11 +3778,12 @@ class Facture extends CommonInvoice
*/
function load_board($user)
{
+ // phpcs:enable
global $conf, $langs;
$clause = " WHERE";
- $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut";
+ $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
@@ -3732,7 +3805,7 @@ class Facture extends CommonInvoice
$response = new WorkboardResponse();
$response->warning_delay=$conf->facture->client->warning_delay/60/60/24;
$response->label=$langs->trans("CustomerBillsUnpaid");
- $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills';
+ $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills';
$response->img=img_object('',"bill");
$generic_facture = new Facture($this->db);
@@ -3743,6 +3816,7 @@ class Facture extends CommonInvoice
$generic_facture->statut = $obj->fk_statut;
$response->nbtodo++;
+ $response->total += $obj->total;
if ($generic_facture->hasDelay()) {
$response->nbtodolate++;
@@ -3942,6 +4016,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -3949,6 +4024,7 @@ class Facture extends CommonInvoice
*/
function load_state_board()
{
+ // phpcs:enable
global $conf, $user;
$this->nb=array();
@@ -4055,6 +4131,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Checks if the invoice is the first of a cycle
*
@@ -4062,9 +4139,11 @@ class Facture extends CommonInvoice
*/
function is_first()
{
+ // phpcs:enable
return ($this->situation_counter == 1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns an array containing the previous situations as Facture objects
*
@@ -4072,6 +4151,7 @@ class Facture extends CommonInvoice
*/
function get_prev_sits()
{
+ // phpcs:enable
global $conf;
$sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture';
@@ -4144,6 +4224,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Checks if the invoice is the last in its cycle
*
@@ -4152,6 +4233,7 @@ class Facture extends CommonInvoice
*/
function is_last_in_cycle()
{
+ // phpcs:enable
global $conf;
if (!empty($this->situation_cycle_ref)) {
@@ -4214,8 +4296,15 @@ class Facture extends CommonInvoice
*/
class FactureLigne extends CommonInvoiceLine
{
- public $element='facturedet';
- public $table_element='facturedet';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='facturedet';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='facturedet';
var $oldline;
@@ -4323,6 +4412,7 @@ class FactureLigne extends CommonInvoiceLine
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
+ $this->id = $objp->rowid;
$this->fk_facture = $objp->fk_facture;
$this->fk_parent_line = $objp->fk_parent_line;
$this->label = $objp->custom_label;
@@ -4773,14 +4863,16 @@ class FactureLigne extends CommonInvoiceLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Mise a jour en base des champs total_xxx de ligne de facture
- * TODO What is goal of this method ?
+ * Update DB line fields total_xxx
+ * Used by migration
*
* @return int <0 if KO, >0 if OK
*/
function update_total()
{
+ // phpcs:enable
$this->db->begin();
dol_syslog(get_class($this)."::update_total", LOG_DEBUG);
@@ -4813,6 +4905,7 @@ class FactureLigne extends CommonInvoiceLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns situation_percent of the previous line.
* Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line.
@@ -4822,6 +4915,7 @@ class FactureLigne extends CommonInvoiceLine
*/
function get_prev_progress($invoiceid)
{
+ // phpcs:enable
if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") {
return 0;
} else {
@@ -4834,7 +4928,7 @@ class FactureLigne extends CommonInvoiceLine
$resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
- return $res['situation_percent'];
+ return floatval($res['situation_percent']);
} else {
$this->error = $this->db->error();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php
index a23d5bdc2c2..ef54a6ffa5f 100644
--- a/htdocs/compta/facture/class/facturestats.class.php
+++ b/htdocs/compta/facture/class/facturestats.class.php
@@ -35,7 +35,11 @@ class FactureStats extends Stats
var $socid;
var $userid;
- public $table_element;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element;
+
var $from;
var $field;
var $where;
@@ -220,7 +224,5 @@ class FactureStats extends Stats
return $this->_getAllByProduct($sql);
}
-
-
}
diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php
index 3697a61672b..619487e9574 100644
--- a/htdocs/compta/facture/class/paymentterm.class.php
+++ b/htdocs/compta/facture/class/paymentterm.class.php
@@ -28,23 +28,38 @@
*/
class PaymentTerm // extends CommonObject
{
- var $db; //!< To store db handler
- var $error; //!< To return error code (or message)
- var $errors=array(); //!< To return several error codes (or messages)
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
//public $element='c_payment_term'; //!< Id that identify managed objects
//public $table_element='c_payment_term'; //!< Name of table without prefix where object is stored
- var $context =array();
+ public $context =array();
- var $id;
+ /**
+ * @var int ID
+ */
+ public $id;
- var $code;
- var $sortorder;
- var $active;
- var $libelle;
- var $libelle_facture;
- var $type_cdr;
- var $nbjour;
- var $decalage;
+ public $code;
+ public $sortorder;
+ public $active;
+ public $libelle;
+ public $libelle_facture;
+ public $type_cdr;
+ public $nbjour;
+ public $decalage;
@@ -467,5 +482,4 @@ class PaymentTerm // extends CommonObject
$this->nbjour='';
$this->decalage='';
}
-
}
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index af872a174ca..ab96700fc53 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -215,6 +215,6 @@ if ($id > 0 || ! empty($ref))
}
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 828c77f1178..0ce8ad7eb92 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
// Load translation files required by the page
@@ -78,7 +78,7 @@ if ($object->fetch($id))
* Actions
*/
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
/*
@@ -104,7 +104,7 @@ if ($id > 0 || ! empty($ref))
$totalpaye = $object->getSommePaiement();
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -191,6 +191,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 6719e7091c8..3fa091e0665 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -1,14 +1,14 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2013 Florian Henry
- * Copyright (C) 2013 Juanjo Menent
- * Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2012 Cedric Salvador
- * Copyright (C) 2015 Alexandre Spangaro
- * Copyright (C) 2016 Meziane Sof
- * Copyright (C) 2017 Frédéric France
+/* Copyright (C) 2002-2003 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Juanjo Menent
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2012 Cedric Salvador
+ * Copyright (C) 2015 Alexandre Spangaro
+ * Copyright (C) 2016 Meziane Sof
+ * Copyright (C) 2017-2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
- //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
@@ -546,7 +546,7 @@ if (empty($reshook))
}
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
- require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db);
@@ -1113,7 +1113,7 @@ if ($action == 'create')
// Date next run
print "".$langs->trans('NextDateToExecution')." ";
$date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
- print $form->select_date($date_next_execution, '', 1, 1, '', "add", 1, 1, 1);
+ print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1);
print " ";
// Number max of generation
@@ -1513,7 +1513,7 @@ else
//var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour'));
if (! $object->isMaxNbGenReached())
{
- if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
+ if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
}
else
{
@@ -1734,6 +1734,6 @@ else
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php
index 8964b85203b..aff7cb362a8 100644
--- a/htdocs/compta/facture/info.php
+++ b/htdocs/compta/facture/info.php
@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
// Load translation files required by the page
@@ -122,5 +122,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 13db00a02c2..cf41f864f05 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -607,7 +607,7 @@ if ($resql)
print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?' ':'') : ''.$langs->trans('NA').' ');
if (! $invoicerectmp->isMaxNbGenReached())
{
- if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
+ if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
}
else
{
@@ -709,6 +709,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 3d983e3216a..3fdfbc0c514 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -79,7 +79,7 @@ $search_montant_vat=GETPOST('search_montant_vat','alpha');
$search_montant_localtax1=GETPOST('search_montant_localtax1','alpha');
$search_montant_localtax2=GETPOST('search_montant_localtax2','alpha');
$search_montant_ttc=GETPOST('search_montant_ttc','alpha');
-$search_status=GETPOST('search_status','int');
+$search_status=GETPOST('search_status','intcomma');
$search_paymentmode=GETPOST('search_paymentmode','int');
$search_town=GETPOST('search_town','alpha');
$search_zip=GETPOST('search_zip','alpha');
@@ -88,13 +88,15 @@ $search_country=GETPOST("search_country",'int');
$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
$search_user = GETPOST('search_user','int');
$search_sale = GETPOST('search_sale','int');
-$search_day = GETPOST('search_day','int');
+$search_day = GETPOST('search_day','int');
$search_month = GETPOST('search_month','int');
$search_year = GETPOST('search_year','int');
-$search_day_lim = GETPOST('search_day_lim','int');
+$search_day_lim = GETPOST('search_day_lim','int');
$search_month_lim = GETPOST('search_month_lim','int');
$search_year_lim = GETPOST('search_year_lim','int');
$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
+$search_btn=GETPOST('button_search','alpha');
+$search_remove_btn=GETPOST('button_removefilter','alpha');
$option = GETPOST('search_option');
if ($option == 'late') {
@@ -106,9 +108,9 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
-if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == 1) $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
+if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='f.datef';
$pageprev = $page - 1;
@@ -146,29 +148,29 @@ if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate";
$checkedtypetiers=0;
$arrayfields=array(
- 'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
- 'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
- 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0),
- 'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1),
- 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1),
- 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
- 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
- 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
- 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
- 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
- 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
- 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
- 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1),
- 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
- 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
+ 'f.facnumber'=>array('label'=>"Ref", 'checked'=>1),
+ 'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1),
+ 'f.type'=>array('label'=>"Type", 'checked'=>0),
+ 'f.date'=>array('label'=>"DateInvoice", 'checked'=>1),
+ 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1),
+ 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
+ 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
+ 's.town'=>array('label'=>"Town", 'checked'=>1),
+ 's.zip'=>array('label'=>"Zip", 'checked'=>1),
+ 'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
+ 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
+ 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
+ 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1),
+ 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
+ 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")),
'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1")),
- 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
- 'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
- 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0),
- 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
- 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
- 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
+ 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
+ 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0),
+ 'rtp'=>array('label'=>"Rest", 'checked'=>0),
+ 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
+ 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
+ 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@@ -268,7 +270,6 @@ if ($massaction == 'withdrawrequest')
$totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
$totaldeposits = $objecttmp->getSumDepositsUsed();
$objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
- $listofbills[] = $objecttmp;
if($objecttmp->paye || $objecttmp->resteapayer==0){
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
@@ -300,18 +301,21 @@ if ($massaction == 'withdrawrequest')
if ($numprlv>0){
$error++;
- setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'errors');
+ setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
}
- if (!empty($objecttmp->mode_reglement_code ) && $objecttmp->mode_reglement_code != 'PRE'){
+ else if (!empty($objecttmp->mode_reglement_code ) && $objecttmp->mode_reglement_code != 'PRE'){
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
}
+ else {
+ $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
+ }
}
}
- //Massive withdraw request
- if(!empty($listofbills) && empty($error))
+ //Massive withdraw request for request with no errors
+ if(!empty($listofbills))
{
$nbwithdrawrequestok=0;
foreach($listofbills as $aBill)
@@ -418,22 +422,14 @@ if ($filtre)
}
if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer);
-if ($search_type != '' && $search_type >= 0)
-{
- if ($search_type == '0') $sql.=" AND f.type = 0"; // standard
- if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement
- if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note
- if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit
- if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
- if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
-}
+if ($search_type != '') $sql.=" AND f.type IN (".$db->escape($search_type).")";
if ($search_project) $sql .= natural_search('p.ref', $search_project);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_town) $sql.= natural_search('s.town', $search_town);
if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
if ($search_state) $sql.= natural_search("state.nom",$search_state);
-if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
-if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
+if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
+if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
@@ -442,12 +438,19 @@ if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $searc
if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL";
-if ($search_status != '' && $search_status >= 0)
+if ($search_status != '-1' && $search_status != '')
{
- if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft
- if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed
- if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
- if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned
+ if (is_numeric($search_status) && $search_status >= 0)
+ {
+ if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft
+ if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed
+ if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
+ if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned
+ }
+ else
+ {
+ $sql.= " AND f.fk_statut IN (".$search_status.")"; // When search_status is '1,2' for example
+ }
}
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
if ($search_month > 0)
@@ -500,8 +503,9 @@ if (! $sall)
$sql.= ' typent.code,';
$sql.= ' state.code_departement, state.nom,';
$sql.= ' country.code,';
- $sql.= " p.rowid, p.ref";
-
+ $sql.= " p.rowid, p.ref, p.title";
+ if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
+ // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by
{
$sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
@@ -565,14 +569,14 @@ if ($resql)
if ($search_zip) $param.='&search_zip='.urlencode($search_zip);
if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale);
if ($search_user > 0) $param.='&search_user=' .urlencode($search_user);
- if ($search_product_category > 0) $param.='$search_product_category=' .urlencode($search_product_category);
+ if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category);
if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht);
if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1);
if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2);
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
- if ($search_paymentmode > 0) $param.='search_paymentmode='.urlencode($search_paymentmode);
+ if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode);
if ($show_files) $param.='&show_files='.urlencode($show_files);
if ($option) $param.="&search_option=".urlencode($option);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
@@ -854,7 +858,7 @@ if ($resql)
if (! empty($arrayfields['f.fk_statut']['checked']))
{
print '';
- $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled"));
+ $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled"));
print $form->selectarray('search_status', $liststatus, $search_status, 1);
print ' ';
}
@@ -912,6 +916,9 @@ if ($resql)
$facturestatic->id=$obj->id;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
+ $facturestatic->total_ht=$obj->total_ht;
+ $facturestatic->total_tva=$obj->total_vat;
+ $facturestatic->total_ttc=$obj->total_ttc;
$facturestatic->statut=$obj->fk_statut;
$facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
$facturestatic->note_public=$obj->note_public;
@@ -1056,11 +1063,20 @@ if ($resql)
if (! empty($arrayfields['typent.code']['checked']))
{
print '';
- if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
+ if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
print $typenArray[$obj->typent_code];
print ' ';
if (! $i) $totalarray['nbfield']++;
}
+ // Staff
+ if (! empty($arrayfields['staff.code']['checked']))
+ {
+ print '';
+ if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
+ print $staffArray[$obj->staff_code];
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
@@ -1238,5 +1254,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 58fc26030b7..c46d3ed690e 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -142,7 +142,6 @@ if ($id > 0 || ! empty($ref))
dol_fiche_end();
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index ecde973bd3b..d7766268989 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -696,6 +696,6 @@ if ($object->id > 0)
print '';
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index 0416e04f7b0..04603076b07 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -347,7 +347,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 09a528b1ce7..ea43c270b5f 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -234,7 +234,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid, s.email";
$sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
- $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
+ $sql.= ", cc.rowid as country_id, cc.code as country_code";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
$sql.= " AND f.entity = ".$conf->entity;
@@ -274,6 +275,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$companystatic->id=$obj->socid;
$companystatic->name=$obj->name;
$companystatic->email=$obj->email;
+ $companystatic->country_id=$obj->country_id;
+ $companystatic->country_code=$obj->country_code;
$companystatic->fournisseur = 1;
$companystatic->code_client = $obj->code_client;
$companystatic->code_fournisseur = $obj->code_fournisseur;
@@ -324,8 +327,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid";
$sql.= ", s.code_client, s.code_compta, s.email";
- $sql.= ", sum(pf.amount) as am";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
+ $sql.= ", cc.rowid as country_id, cc.code as country_code";
+ $sql.= ", sum(pf.amount) as am";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc";
@@ -338,7 +342,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
- $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email";
+ $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,";
+ $sql.= " cc.rowid, cc.code";
$sql.= " ORDER BY f.tms DESC ";
$sql.= $db->plimit($max, 0);
@@ -375,6 +380,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name;
$thirdpartystatic->email=$obj->email;
+ $thirdpartystatic->country_id=$obj->country_id;
+ $thirdpartystatic->country_code=$obj->country_code;
+ $thirdpartystatic->email=$obj->email;
$thirdpartystatic->client=1;
$thirdpartystatic->code_client = $obj->code_client;
//$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
@@ -696,8 +704,9 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
$sql.= ", s.nom as name, s.email";
$sql.= ", s.rowid as socid";
$sql.= ", s.code_client, s.code_compta";
- $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
+ $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,";
+ $sql.= " cc.rowid as country_id, cc.code as country_code";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'";
@@ -713,7 +722,7 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
$reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill',$parameters);
$sql.=$hookmanager->resPrint;
- $sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc";
+ $sql.= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code";
$resql = $db->query($sql);
if ( $resql )
@@ -741,6 +750,8 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
$societestatic->id=$obj->socid;
$societestatic->name=$obj->name;
$societestatic->email=$obj->email;
+ $societestatic->country_id=$obj->country_id;
+ $societestatic->country_code=$obj->country_code;
$societestatic->client=1;
$societestatic->code_client = $obj->code_client;
//$societestatic->code_fournisseur = $obj->code_fournisseur;
@@ -813,8 +824,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid, s.email";
$sql.= ", s.code_client, s.code_compta";
- $sql.= ", sum(pf.amount) as am";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
+ $sql.= ", cc.rowid as country_id, cc.code as country_code";
+ $sql.= ", sum(pf.amount) as am";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
@@ -827,7 +839,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
- $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta";
+ $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
$sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
$resql = $db->query($sql);
@@ -865,6 +877,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$societestatic->id=$obj->socid;
$societestatic->name=$obj->name;
$societestatic->email=$obj->email;
+ $societestatic->country_id=$obj->country_id;
+ $societestatic->country_code=$obj->country_code;
$societestatic->client=1;
$societestatic->code_client = $obj->code_client;
$societestatic->code_fournisseur = $obj->code_fournisseur;
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index 2bc754ccf11..2d43d48d778 100644
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -1,10 +1,11 @@
- * Copyright (C) 2007-2010 Jean Heimburger
- * Copyright (C) 2011-2014 Juanjo Menent
- * Copyright (C) 2012 Regis Houssin
- * Copyright (C) 2011-2012 Alexandre spangaro
- * Copyright (C) 2013 Marcos García
+/* Copyright (C) 2007-2010 Laurent Destailleur
+ * Copyright (C) 2007-2010 Jean Heimburger
+ * Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2011-2012 Alexandre spangaro
+ * Copyright (C) 2013 Marcos García
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -80,7 +81,8 @@ $date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
- $date_start=dol_get_first_day($pastmonthyear,$pastmonth,false); $date_end=dol_get_last_day($pastmonthyear,$pastmonth,false);
+ $date_start=dol_get_first_day($pastmonthyear,$pastmonth,false);
+ $date_end=dol_get_last_day($pastmonthyear,$pastmonth,false);
}
$name=$langs->trans("PurchasesJournal");
@@ -90,7 +92,7 @@ $builddate=dol_now();
$description=$langs->trans("DescPurchasesJournal").' ';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink);
@@ -251,8 +253,6 @@ foreach ($tabfac as $key => $val)
print "";
-
// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index 24b36cf76c0..3b4be22a81d 100644
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2007-2010 Jean Heimburger
- * Copyright (C) 2011-2014 Juanjo Menent
- * Copyright (C) 2012 Regis Houssin
- * Copyright (C) 2011-2012 Alexandre Spangaro
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2013 Marcos García
- * Copyright (C) 2014 Raphaël Doursenaud
+/* Copyright (C) 2007-2010 Laurent Destailleur
+ * Copyright (C) 2007-2010 Jean Heimburger
+ * Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2011-2012 Alexandre Spangaro
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2013 Marcos García
+ * Copyright (C) 2014 Raphaël Doursenaud
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -93,7 +94,7 @@ $builddate=dol_now();
$description=$langs->trans("DescSellsJournal").' ';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink);
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
@@ -282,7 +283,6 @@ foreach ($tabfac as $key => $val)
print "";
-
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php
index e8a84fcc9e1..222423b7c67 100644
--- a/htdocs/compta/localtax/card.php
+++ b/htdocs/compta/localtax/card.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2015 Marcos García
+/* Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2015 Marcos García
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -172,11 +173,11 @@ if ($action == 'create')
print "";
print ''.$langs->trans("DatePayment").' ';
- print $form->select_date($datep,"datep",'','','','add',1,1);
+ print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print ' ';
print ''.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).' ';
- print $form->select_date($datev,"datev",'','','','add',1,1);
+ print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1);
print ' ';
// Label
@@ -299,6 +300,6 @@ if ($id)
print "";
}
+// End of page
llxFooter();
$db->close();
-
diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php
index a75de537724..6838f9a65b2 100644
--- a/htdocs/compta/localtax/class/localtax.class.php
+++ b/htdocs/compta/localtax/class/localtax.class.php
@@ -29,19 +29,35 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Localtax extends CommonObject
{
- public $element='localtax'; //!< Id that identify managed objects
- public $table_element='localtax'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='localtax';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='localtax';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='payment';
- var $ltt;
- var $tms;
- var $datep;
- var $datev;
- var $amount;
- var $label;
- var $fk_bank;
- var $fk_user_creat;
- var $fk_user_modif;
+ public $ltt;
+ public $tms;
+ public $datep;
+ public $datev;
+ public $amount;
+
+ /**
+ * @var string local tax
+ */
+ public $label;
+
+ public $fk_bank;
+ public $fk_user_creat;
+ public $fk_user_modif;
/**
* Constructor
@@ -331,6 +347,7 @@ class Localtax extends CommonObject
return $solde;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Total de la localtax des factures emises par la societe.
*
@@ -339,6 +356,7 @@ class Localtax extends CommonObject
*/
function localtax_sum_collectee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.localtax) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
if ($year)
@@ -369,6 +387,7 @@ class Localtax extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* localtax payed
*
@@ -377,6 +396,7 @@ class Localtax extends CommonObject
*/
function localtax_sum_payee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.total_localtax) as total_localtax";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
@@ -409,6 +429,7 @@ class Localtax extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* localtax payed
* Total de la localtax payed
@@ -418,6 +439,7 @@ class Localtax extends CommonObject
*/
function localtax_sum_reglee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
@@ -563,6 +585,7 @@ class Localtax extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update the link betwen localtax payment and the line into llx_bank
*
@@ -571,6 +594,7 @@ class Localtax extends CommonObject
*/
function update_fk_bank($id)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -622,18 +646,19 @@ class Localtax extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
* @param int $status Statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @return string Libelle du statut
+ * @return string Libelle du statut
*/
- function LibStatut($status,$mode=0)
- {
- global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
-
- return '';
- }
+ function LibStatut($status, $mode=0)
+ {
+ // phpcs:enable
+ global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
+ return '';
+ }
}
diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index 9502ff46d2d..8f986697a01 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2014 Ferran Marcet
+/* Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -117,7 +118,7 @@ if ($calc==0 || $calc==1) // Calculate on invoice for goods and services
{
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.=' '.$langs->trans("WarningDepositsNotIncluded");
$description.=$fsearch;
$description.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
@@ -134,7 +135,7 @@ if ($calc==2) // Invoice for goods, payment for services
{
$calcmode=$langs->trans("CalcModeLT2Debt");
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.=' '.$langs->trans("WarningDepositsNotIncluded");
$description.=$fsearch;
$description.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
@@ -325,5 +326,6 @@ if($calc ==0){
}
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php
index c62034ee65c..1e2c26c0c62 100644
--- a/htdocs/compta/localtax/index.php
+++ b/htdocs/compta/localtax/index.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2014 Ferran Marcet
- * Copyright (C) 2018 Laurent Destailleur
+/* Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2018 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -223,7 +224,7 @@ $calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/adm
//if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.=' '.$langs->trans("ThisIsAnEstimatedValue");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$builddate=dol_now();
@@ -587,5 +588,6 @@ pt($db, $sql, $langs->trans("Month"));
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php
index 0e32a249f17..37ead35433c 100644
--- a/htdocs/compta/localtax/list.php
+++ b/htdocs/compta/localtax/list.php
@@ -103,5 +103,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php
index 31729693f37..e49f42bb14f 100644
--- a/htdocs/compta/localtax/quadri_detail.php
+++ b/htdocs/compta/localtax/quadri_detail.php
@@ -4,6 +4,7 @@
* Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2006-2007 Yannick Warnier
* Copyright (C) 2014-2016 Juanjo Menent
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -132,18 +133,22 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
-$prevyear=$year_start; $prevquarter=$q;
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
+$prevyear=$year_start;
+$prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
- $prevquarter=4; $prevyear--;
+ $prevquarter=4;
+ $prevyear--;
}
-$nextyear=$year_start; $nextquarter=$q;
+$nextyear=$year_start;
+$nextquarter=$q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
- $nextquarter=1; $nextyear++;
+ $nextquarter=1;
+ $nextyear++;
}
$description.=$fsearch;
$builddate=dol_now();
@@ -209,7 +214,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$langs->load("errors");
if ($x_coll == -1)
print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").' ';
- else if ($x_coll == -2)
+ elseif ($x_coll == -2)
print ''.$langs->trans("FeatureNotYetAvailable").' ';
else
print ''.$langs->trans("Error").' ';
@@ -640,5 +645,6 @@ else
}
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index c2ce95dd827..764ca818f7f 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -1,13 +1,14 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2014 Raphaël Doursenaud
- * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
- * Copyright (C) 2015 Juanjo Menent
+/* Copyright (C) 2001-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2014 Raphaël Doursenaud
+ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
+ * Copyright (C) 2015 Juanjo Menent
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -467,7 +468,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print ''.$langs->trans('Date').' ';
$datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment);
- $form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date);
+ print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date);
print ' ';
// Payment mode
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index 656d6c673f2..31c557373d0 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -450,6 +450,6 @@ if ($user->societe_id == 0 && $action == '')
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 69f3bd102df..1f7b344f62d 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -5,6 +5,7 @@
* Copyright (C) 2011-2016 Juanjo Menent
* Copyright (C) 2013 Philippe Grand
* Copyright (C) 2015-2016 Alexandre Spangaro
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -273,7 +274,7 @@ else if ($action == 'remove_file' && $user->rights->banque->cheque)
{
if ($object->fetch($id) > 0)
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("other");
@@ -386,7 +387,7 @@ if ($action == 'new')
//print ''.$langs->trans('Date').' '.dol_print_date($now,'day').' ';
// Filter
print ''.$langs->trans("DateChequeReceived").' ';
- print $form->select_date($filterdate,'fd',0,0,1,'',1,1,1);
+ print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
print ' ';
print ''.$langs->trans("BankAccount").' ';
$form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
@@ -586,7 +587,7 @@ else
print 'id.'" method="post">';
print ' ';
print ' ';
- $form->select_date($object->date_bordereau,'datecreate_','','','',"setdate");
+ print $form->selectDate($object->date_bordereau, 'datecreate_', '', '', '', "setdate");
print ' ';
print ' ';
}
@@ -806,8 +807,6 @@ if ($action != 'new')
}
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index 528b01477a6..ade6895ac41 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -33,14 +33,25 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
*/
class RemiseCheque extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='chequereceipt';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='bordereau_cheque';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'payment';
- var $num;
- var $intitule;
+ public $num;
+ public $intitule;
//! Numero d'erreur Plage 1024-1279
- var $errno;
+ public $errno;
public $amount;
public $date_bordereau;
@@ -48,6 +59,10 @@ class RemiseCheque extends CommonObject
public $account_label;
public $author_id;
public $nbcheque;
+
+ /**
+ * @var string Ref
+ */
public $ref;
/**
@@ -480,6 +495,7 @@ class RemiseCheque extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -488,6 +504,7 @@ class RemiseCheque extends CommonObject
*/
function load_board($user)
{
+ // phpcs:enable
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -533,6 +550,7 @@ class RemiseCheque extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge indicateurs this->nb de tableau de bord
*
@@ -540,6 +558,7 @@ class RemiseCheque extends CommonObject
*/
function load_state_board()
{
+ // phpcs:enable
global $user;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -593,8 +612,8 @@ class RemiseCheque extends CommonObject
$file = "pdf_".$model.".class.php";
if (file_exists($dir.$file))
{
- require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
- require_once $dir.$file;
+ include_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
+ include_once $dir.$file;
$classname='BordereauCheque'.ucfirst($model);
$docmodel = new $classname($this->db);
@@ -847,13 +866,15 @@ class RemiseCheque extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge les proprietes ref_previous et ref_next
*
- * @return int <0 if KO, 0 if OK
+ * @return int <0 if KO, 0 if OK
*/
function load_previous_next_id()
{
+ // phpcs:enable
global $conf;
$this->errno = 0;
@@ -888,6 +909,7 @@ class RemiseCheque extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set the creation date
*
@@ -897,6 +919,7 @@ class RemiseCheque extends CommonObject
*/
function set_date($user, $date)
{
+ // phpcs:enable
if ($user->rights->banque->cheque)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
@@ -922,6 +945,7 @@ class RemiseCheque extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set the ref of bordereau
*
@@ -931,6 +955,7 @@ class RemiseCheque extends CommonObject
*/
function set_number($user, $ref)
{
+ // phpcs:enable
if ($user->rights->banque->cheque)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
@@ -1044,6 +1069,7 @@ class RemiseCheque extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a status
*
@@ -1053,6 +1079,7 @@ class RemiseCheque extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
if ($mode == 0)
@@ -1060,37 +1087,36 @@ class RemiseCheque extends CommonObject
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
return $langs->trans('Unknown');
}
-
}
diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php
index 527bd05e3a1..ecb035caeb8 100644
--- a/htdocs/compta/paiement/cheque/index.php
+++ b/htdocs/compta/paiement/cheque/index.php
@@ -24,7 +24,7 @@
* \brief Home page for cheque receipts
*/
-require('../../../main.inc.php');
+require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -151,6 +151,6 @@ else
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index 800f40b9694..2f0c6592694 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -25,7 +25,7 @@
* \brief Page list of cheque deposits
*/
-require('../../../main.inc.php');
+require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -250,6 +250,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php
index 59f13023b24..c9794d9662e 100644
--- a/htdocs/compta/paiement/class/cpaiement.class.php
+++ b/htdocs/compta/paiement/class/cpaiement.class.php
@@ -34,15 +34,12 @@ class Cpaiement
* @var string Id to identify managed objects
*/
public $element = 'cpaiement';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'c_paiement';
-
- /**
- */
-
public $code;
public $libelle;
public $type;
@@ -50,9 +47,6 @@ class Cpaiement
public $accountancy_code;
public $module;
- /**
- */
-
/**
* Constructor
@@ -375,8 +369,5 @@ class Cpaiement
$this->active = '';
$this->accountancy_code = '';
$this->module = '';
-
-
}
-
}
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 539c70f591b..952f478087b 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -36,36 +36,50 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php';
*/
class Paiement extends CommonObject
{
- public $element='payment';
- public $table_element='paiement';
- public $picto = 'payment';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='payment';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='paiement';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'payment';
+
+ public $facid;
+ public $datepaye;
- var $facid;
- var $datepaye;
/**
* @deprecated
* @see amount, amounts
*/
- var $total;
+ public $total;
+
/**
* @deprecated
* @see amount, amounts
*/
- var $montant;
- var $amount; // Total amount of payment
- var $amounts=array(); // Array of amounts
- var $multicurrency_amounts=array(); // Array of amounts
- var $author;
- var $paiementid; // Type de paiement. Stocke dans fk_paiement
+ public $montant;
+
+ public $amount; // Total amount of payment
+ public $amounts=array(); // Array of amounts
+ public $multicurrency_amounts=array(); // Array of amounts
+ public $author;
+ public $paiementid; // Type de paiement. Stocke dans fk_paiement
// de llx_paiement qui est lie aux types de
//paiement de llx_c_paiement
- var $num_paiement; // Numero du CHQ, VIR, etc...
- var $num_payment; // Numero du CHQ, VIR, etc...
- var $bank_account; // Id compte bancaire du paiement
- var $bank_line; // Id de la ligne d'ecriture bancaire
+ public $num_paiement; // Numero du CHQ, VIR, etc...
+ public $num_payment; // Numero du CHQ, VIR, etc...
+ public $bank_account; // Id compte bancaire du paiement
+ public $bank_line; // Id de la ligne d'ecriture bancaire
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
// fk_paiement dans llx_paiement_facture est le rowid du paiement
- var $fk_paiement; // Type of paiment
+ public $fk_paiement; // Type of paiment
/**
@@ -545,7 +559,7 @@ class Paiement extends CommonObject
$this->fk_account=$accountid;
- require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
dol_syslog("$user->id,$mode,$label,$this->fk_account,$emetteur_nom,$emetteur_banque");
@@ -694,6 +708,7 @@ class Paiement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Mise a jour du lien entre le paiement et la ligne generee dans llx_bank
*
@@ -702,6 +717,7 @@ class Paiement extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
@@ -719,6 +735,7 @@ class Paiement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Updates the payment date
*
@@ -727,6 +744,7 @@ class Paiement extends CommonObject
*/
function update_date($date)
{
+ // phpcs:enable
if (!empty($date) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
@@ -750,6 +768,7 @@ class Paiement extends CommonObject
return -1; //no date given or already validated
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Updates the payment number
*
@@ -758,6 +777,7 @@ class Paiement extends CommonObject
*/
function update_num($num)
{
+ // phpcs:enable
if(!empty($num) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
@@ -1064,7 +1084,7 @@ class Paiement extends CommonObject
$arraybill = $this->getBillsArray();
if (is_array($arraybill) && count($arraybill) > 0)
{
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($this->db);
foreach ($arraybill as $billid)
{
@@ -1112,6 +1132,7 @@ class Paiement extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -1121,6 +1142,7 @@ class Paiement extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
@@ -1162,15 +1184,17 @@ class Paiement extends CommonObject
return '';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Load the third party of object, from id into this->thirdparty
+ * Load the third party of object, from id into this->thirdparty
*
- * @param int $force_thirdparty_id Force thirdparty id
- * @return int <0 if KO, >0 if OK
+ * @param int $force_thirdparty_id Force thirdparty id
+ * @return int <0 if KO, >0 if OK
*/
function fetch_thirdparty($force_thirdparty_id=0)
{
- require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+ // phpcs:enable
+ include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
if (empty($force_thirdparty_id))
{
diff --git a/htdocs/compta/paiement/index.php b/htdocs/compta/paiement/index.php
index 7f1597b5afc..5bcda011615 100644
--- a/htdocs/compta/paiement/index.php
+++ b/htdocs/compta/paiement/index.php
@@ -31,5 +31,6 @@ llxHeader();
print load_fiche_titre("Payments");
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php
index 9f55761dba0..86e45508b2c 100644
--- a/htdocs/compta/paiement/info.php
+++ b/htdocs/compta/paiement/info.php
@@ -76,5 +76,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 064ca877c3f..5b5124b2b80 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -371,5 +371,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php
index 3e6427f6ac2..c2c63aea84d 100644
--- a/htdocs/compta/paiement/rapport.php
+++ b/htdocs/compta/paiement/rapport.php
@@ -166,6 +166,6 @@ if ($year)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php
index e60f65f924e..9fea9afa5df 100644
--- a/htdocs/compta/paiement/tovalidate.php
+++ b/htdocs/compta/paiement/tovalidate.php
@@ -139,5 +139,6 @@ if ($resql)
print "";
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php
index fba8723d818..9b605e68929 100644
--- a/htdocs/compta/paiement_charge.php
+++ b/htdocs/compta/paiement_charge.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2016 Frédéric France
+/* Copyright (C) 2004-2014 Laurent Destailleur
+ * Copyright (C) 2016-2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,9 +17,9 @@
*/
/**
- * \file htdocs/compta/paiement_charge.php
- * \ingroup tax
- * \brief Page to add payment of a tax
+ * \file htdocs/compta/paiement_charge.php
+ * \ingroup tax
+ * \brief Page to add payment of a tax
*/
require '../main.inc.php';
@@ -226,7 +226,7 @@ if ($action == 'create')
print ''.$langs->trans("Date").' ';
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
- $form->select_date($datepayment,'','','','',"add_payment",1,1);
+ print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print " ";
print ' ';
diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php
index b395016aeed..b22d4d21e43 100644
--- a/htdocs/compta/payment_sc/card.php
+++ b/htdocs/compta/payment_sc/card.php
@@ -323,8 +323,6 @@ if ($action == '')
print '';
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php
index 0cbaa9ce55e..a6d1f480a06 100644
--- a/htdocs/compta/prelevement/bons.php
+++ b/htdocs/compta/prelevement/bons.php
@@ -24,7 +24,7 @@
* \brief Page liste des bons de prelevements
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -183,7 +183,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index 343a45472b6..60e471d712d 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2005-2010 Laurent Destailleur
- * Copyright (C) 2010-2016 Juanjo Menent
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2005-2010 Laurent Destailleur
+ * Copyright (C) 2010-2016 Juanjo Menent
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,22 +24,18 @@
* \brief Card of a direct debit
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories'));
+$langs->loadLangs(array('banks', 'categories','bills','withdrawals'));
if (!$user->rights->prelevement->bons->lire)
accessforbidden();
-$langs->load("bills");
-$langs->load("withdrawals");
-
-
// Security check
if ($user->societe_id > 0) accessforbidden();
@@ -244,7 +241,7 @@ if ($id > 0 || $ref)
print '';
print ''.$langs->trans("NotifyTransmision").' ';
print ''.$langs->trans("TransData").' ';
- print $form->select_date('','','','','',"userfile",1,1);
+ print $form->selectDate('', '', '', '', '', "userfile", 1, 1);
print ' ';
print ''.$langs->trans("TransMetod").' ';
print $form->selectarray("methode",$object->methodes_trans);
@@ -268,7 +265,7 @@ if ($id > 0 || $ref)
print ' ';
print ''.$langs->trans("NotifyCredit").' ';
print ''.$langs->trans('CreditDate').' ';
- print $form->select_date('','','','','',"infocredit",1,1);
+ print $form->selectDate('', '', '', '', '', "infocredit", 1, 1);
print ' ';
print '';
print ' '.$langs->trans("ThisWillAlsoAddPaymentOnInvoice");
@@ -419,6 +416,6 @@ if ($id > 0 || $ref)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 245b25be3b6..7b93966aa8b 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -39,29 +39,40 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
*/
class BonPrelevement extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='widthdraw';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='prelevement_bons';
- public $picto = 'payment';
- var $date_echeance;
- var $raison_sociale;
- var $reference_remise;
- var $emetteur_code_guichet;
- var $emetteur_numero_compte;
- var $emetteur_code_banque;
- var $emetteur_number_key;
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'payment';
- var $emetteur_iban;
- var $emetteur_bic;
- var $emetteur_ics;
+ public $date_echeance;
+ public $raison_sociale;
+ public $reference_remise;
+ public $emetteur_code_guichet;
+ public $emetteur_numero_compte;
+ public $emetteur_code_banque;
+ public $emetteur_number_key;
- var $total;
- var $_fetched;
- var $statut; // 0-Wait, 1-Trans, 2-Done
- var $labelstatut=array();
+ public $emetteur_iban;
+ public $emetteur_bic;
+ public $emetteur_ics;
- var $invoice_in_error=array();
- var $thirdparty_in_error=array();
+ public $total;
+ public $fetched;
+ public $statut; // 0-Wait, 1-Trans, 2-Done
+ public $labelstatut=array();
+
+ public $invoice_in_error=array();
+ public $thirdparty_in_error=array();
/**
@@ -98,9 +109,10 @@ class BonPrelevement extends CommonObject
$this->methodes_trans[0] = "Internet";
- $this->_fetched = 0;
+ $this->fetched = 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add invoice to withdrawal
*
@@ -116,6 +128,7 @@ class BonPrelevement extends CommonObject
*/
function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
{
+ // phpcs:enable
$result = 0;
$line_id = 0;
@@ -156,7 +169,6 @@ class BonPrelevement extends CommonObject
}
return $result;
-
}
/**
@@ -304,7 +316,7 @@ class BonPrelevement extends CommonObject
$this->statut = $obj->statut;
- $this->_fetched = 1;
+ $this->fetched = 1;
return 1;
}
@@ -320,6 +332,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set credite and set status of linked invoices. Still used ??
*
@@ -327,6 +340,7 @@ class BonPrelevement extends CommonObject
*/
function set_credite()
{
+ // phpcs:enable
global $user,$conf;
$error = 0;
@@ -397,6 +411,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set direct debit order to "credited" status.
*
@@ -406,11 +421,12 @@ class BonPrelevement extends CommonObject
*/
function set_infocredit($user, $date)
{
+ // phpcs:enable
global $conf,$langs;
$error = 0;
- if ($this->_fetched == 1)
+ if ($this->fetched == 1)
{
if ($date >= $this->date_trans)
{
@@ -543,6 +559,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set withdrawal to transmited status
*
@@ -553,6 +570,7 @@ class BonPrelevement extends CommonObject
*/
function set_infotrans($user, $date, $method)
{
+ // phpcs:enable
global $conf,$langs;
$error = 0;
@@ -667,6 +685,7 @@ class BonPrelevement extends CommonObject
return $arr;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns amount of withdrawal
*
@@ -674,6 +693,7 @@ class BonPrelevement extends CommonObject
*/
function SommeAPrelever()
{
+ // phpcs:enable
global $conf;
$sql = "SELECT sum(pfd.amount) as nb";
@@ -704,6 +724,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get number of invoices to withdrawal
* TODO delete params banque and agence when not necesary
@@ -714,6 +735,7 @@ class BonPrelevement extends CommonObject
*/
function NbFactureAPrelever($banque=0,$agence=0)
{
+ // phpcs:enable
global $conf;
$sql = "SELECT count(f.rowid) as nb";
@@ -745,6 +767,7 @@ class BonPrelevement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Create a withdraw
* TODO delete params banque and agence when not necesary
@@ -758,20 +781,21 @@ class BonPrelevement extends CommonObject
*/
function Create($banque=0, $agence=0, $mode='real', $format='ALL',$executiondate='')
{
+ // phpcs:enable
global $conf,$langs;
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG);
- require_once (DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
- require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+ require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
+ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
if (empty($format)) return 'ErrorBadParametersForDirectDebitFileCreate';
$error = 0;
$datetimeprev = time();
- //Choice the date of the execution direct debit
- if(!empty($executiondate)) $datetimeprev = $executiondate;
+ //Choice the date of the execution direct debit
+ if(!empty($executiondate)) $datetimeprev = $executiondate;
$month = strftime("%m", $datetimeprev);
$year = strftime("%Y", $datetimeprev);
@@ -1180,6 +1204,7 @@ class BonPrelevement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete a notification def by id
*
@@ -1188,6 +1213,7 @@ class BonPrelevement extends CommonObject
*/
function DeleteNotificationById($rowid)
{
+ // phpcs:enable
$result = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
@@ -1203,6 +1229,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete a notification
*
@@ -1212,6 +1239,7 @@ class BonPrelevement extends CommonObject
*/
function DeleteNotification($user, $action)
{
+ // phpcs:enable
$result = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
@@ -1227,6 +1255,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a notification
*
@@ -1237,6 +1266,7 @@ class BonPrelevement extends CommonObject
*/
function AddNotification($db, $user, $action)
{
+ // phpcs:enable
$result = 0;
if ($this->DeleteNotification($user, $action) == 0)
@@ -1449,10 +1479,10 @@ class BonPrelevement extends CommonObject
if (! empty($conf->global->MAIN_UMASK))
@chmod($this->file, octdec($conf->global->MAIN_UMASK));
return $result;
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write recipient of request (customer)
*
@@ -1469,6 +1499,7 @@ class BonPrelevement extends CommonObject
*/
function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $facnumber, $facid, $rib_dom='')
{
+ // phpcs:enable
fputs($this->file, "06");
fputs($this->file, "08"); // Prelevement ordinaire
@@ -1539,6 +1570,7 @@ class BonPrelevement extends CommonObject
return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write recipient of request (customer)
*
@@ -1562,6 +1594,7 @@ class BonPrelevement extends CommonObject
*/
function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum)
{
+ // phpcs:enable
$CrLf = "\n";
$Rowing = sprintf("%06d", $row_idfac);
@@ -1575,7 +1608,8 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR ='';
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
- $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).' '.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).' '.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ $XML_DEBITOR .=' '.(($conf->global->END_TO_END != "" ) ? $conf->global->END_TO_END : ('AS-'.dol_trunc($row_facnumber,20)).'-'.$Rowing).' '.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.round($row_somme, 2).' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
@@ -1607,13 +1641,15 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
// $XML_DEBITOR .=' '.($row_facnumber.'/'.$Rowing.'/'.$Rum).' '.$CrLf;
- $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).' '.$CrLf; // 140 max
+ // $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).' '.$CrLf; // 140 max
+ $XML_DEBITOR .=' '.(($conf->global->USTRD != "" ) ? $conf->global->USTRD : dol_trunc($row_facnumber, 135) ).' '.$CrLf; // 140 max
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
return $XML_DEBITOR;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write sender of request (me)
*
@@ -1621,6 +1657,7 @@ class BonPrelevement extends CommonObject
*/
function EnregEmetteur()
{
+ // phpcs:enable
fputs($this->file, "03");
fputs($this->file, "08"); // Prelevement ordinaire
@@ -1677,9 +1714,9 @@ class BonPrelevement extends CommonObject
fputs($this->file, substr(" ",0,5));
fputs($this->file, "\n");
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write sender of request (me).
* Note: The tag PmtInf is opened here but closed into caller
@@ -1694,6 +1731,7 @@ class BonPrelevement extends CommonObject
*/
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n', $format='FRST')
{
+ // phpcs:enable
// SEPA INITIALISATION
global $conf;
@@ -1801,6 +1839,7 @@ class BonPrelevement extends CommonObject
return $XML_SEPA_INFO;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write end
*
@@ -1809,6 +1848,7 @@ class BonPrelevement extends CommonObject
*/
function EnregTotal($total)
{
+ // phpcs:enable
fputs($this->file, "08");
fputs($this->file, "08"); // Prelevement ordinaire
@@ -1873,6 +1913,7 @@ class BonPrelevement extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return status label for a status
*
@@ -1882,6 +1923,7 @@ class BonPrelevement extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
if (empty($this->labelstatut))
{
global $langs;
@@ -1891,45 +1933,39 @@ class BonPrelevement extends CommonObject
$this->labelstatut[2]=$langs->trans("StatusCredited");
}
- if ($mode == 0)
+ if ($mode == 0 || $mode == 1)
{
return $this->labelstatut[$statut];
}
- if ($mode == 1)
- {
- return $this->labelstatut[$statut];
- }
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut];
if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut];
if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut];
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1');
if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3');
if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut];
if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut];
if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut];
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1');
if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3');
if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1');
if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3');
if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6');
}
}
-
}
-
diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php
index fa8545c4ea2..d8434caefd8 100644
--- a/htdocs/compta/prelevement/class/ligneprelevement.class.php
+++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php
@@ -31,8 +31,15 @@
*/
class LignePrelevement
{
- var $id;
- var $db;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $statuts = array();
@@ -121,6 +128,7 @@ class LignePrelevement
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return status label for a status
*
@@ -130,25 +138,26 @@ class LignePrelevement
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6');
@@ -173,4 +182,3 @@ class LignePrelevement
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}
-
diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php
index 87de138e63a..6e3cfe499a8 100644
--- a/htdocs/compta/prelevement/class/rejetprelevement.class.php
+++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php
@@ -30,8 +30,15 @@
*/
class RejetPrelevement
{
- var $id;
- var $db;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
/**
@@ -62,7 +69,6 @@ class RejetPrelevement
$this->facturer[0]=$langs->trans("NoInvoiceRefused");
$this->facturer[1]=$langs->trans("InvoiceRefused");
-
}
/**
@@ -191,9 +197,9 @@ class RejetPrelevement
dol_syslog("RejetPrelevement::Create Rollback");
$this->db->rollback();
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Send email to all users that has asked the withdraw request
*
@@ -202,6 +208,7 @@ class RejetPrelevement
*/
function _send_email($fac)
{
+ // phpcs:enable
global $langs;
$userid = 0;
@@ -320,7 +327,6 @@ class RejetPrelevement
}
return $arr;
-
}
/**
@@ -364,6 +370,4 @@ class RejetPrelevement
return -2;
}
}
-
}
-
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index 74bd282d606..0d07c341458 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2010-2015 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2010-2012 Juanjo Menent
- * Copyright (C) 2018 Nicolas ZABOURI
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2010-2015 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2010-2012 Juanjo Menent
+ * Copyright (C) 2018 Nicolas ZABOURI
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,7 +26,7 @@
* \brief Prelevement creation page
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -45,7 +46,10 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha')?GETPOST('mode','alpha'):'real';
$format = GETPOST('format','aZ09');
-
+$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
+$page = GETPOST("page",'int');
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+$offset = $limit * $page;
/*
* Actions
@@ -150,7 +154,7 @@ print ' '
if ($nb) {
if ($pricetowithdraw) {
print $langs->trans('ExecutionDate').' ';
- print $form->select_date();
+ print $form->selectDate();
if ($mysoc->isInEEC()) {
print ''.$langs->trans('SEPAFRST').' '.$langs->trans('SEPARCUR').' ';
print ' ';
@@ -196,13 +200,33 @@ $sql.= " AND pfd.traite = 0";
$sql.= " AND pfd.fk_facture = f.rowid";
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
+$nbtotalofrecords = '';
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+}
+
+$sql.= $db->plimit($limit+1,$offset);
+
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
- print load_fiche_titre($langs->trans("InvoiceWaitingWithdraw").($num > 0?' ('.$num.')':''),'','');
+ $param='';
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+ if($socid) $param .= '&socid='.urlencode($socid);
+ if($option) $param .= "&option=".urlencode($option);
+
+ if(! empty($page) && $num <= $nbtotalofrecords) $page = 0;
+
+ print '';
+ print ' ';
+ print ' ';
+
+ print_barre_liste($langs->trans("InvoiceWaitingWithdraw"),$page,$_SERVER['PHP_SELF'],$param,'','','',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
print '';
print '';
@@ -219,7 +243,7 @@ if ($resql)
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$bac = new CompanyBankAccount($db);
- while ($i < $num && $i < 20)
+ while ($i < $num && $i < $limit)
{
$obj = $db->fetch_object($resql);
@@ -260,6 +284,7 @@ if ($resql)
}
else print ' '.$langs->trans("None").' ';
print "
";
+ print " ";
print " \n";
}
else
@@ -324,5 +349,6 @@ else
}
*/
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php
index d20f92cb188..10c390ed5bd 100644
--- a/htdocs/compta/prelevement/demandes.php
+++ b/htdocs/compta/prelevement/demandes.php
@@ -24,7 +24,7 @@
* \brief Page to list withdraw requests
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/modPrelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -167,5 +167,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index 2eabd64873d..df71dcb3f31 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -24,7 +24,7 @@
* \brief Page liste des factures prelevees
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
@@ -296,7 +296,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index 113153bc896..3819c145851 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -24,7 +24,7 @@
* \brief Withdraw reject
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
@@ -245,5 +245,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php
index c126212f17c..a3a1d06e322 100644
--- a/htdocs/compta/prelevement/fiche-stat.php
+++ b/htdocs/compta/prelevement/fiche-stat.php
@@ -23,7 +23,7 @@
* \brief Prelevement statistics
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
@@ -193,5 +193,6 @@ if ($prev_id > 0 || $ref)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php
index de99b56eb19..673b83d15aa 100644
--- a/htdocs/compta/prelevement/index.php
+++ b/htdocs/compta/prelevement/index.php
@@ -26,7 +26,7 @@
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -221,6 +221,6 @@ else
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/ligne.php b/htdocs/compta/prelevement/ligne.php
index 721cf62bcd7..8dd1c87069a 100644
--- a/htdocs/compta/prelevement/ligne.php
+++ b/htdocs/compta/prelevement/ligne.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2005-2012 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2010-2013 Juanjo Menent
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2005-2012 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2010-2013 Juanjo Menent
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,7 +25,7 @@
* \brief card of withdraw line
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
@@ -196,7 +197,7 @@ if ($id)
//Date
print ''.$langs->trans("RefusedData").' ';
print '';
- print $form->select_date('','','','','',"confirm_rejet");
+ print $form->selectDate('', '', '', '', '', "confirm_rejet");
print ' ';
//Reason
@@ -334,6 +335,6 @@ if ($id)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php
index 8d657f00221..ead1bfff08f 100644
--- a/htdocs/compta/prelevement/list.php
+++ b/htdocs/compta/prelevement/list.php
@@ -24,7 +24,7 @@
* \brief Page liste des prelevements
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -213,5 +213,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php
index c8812bba1a9..5c38b29954e 100644
--- a/htdocs/compta/prelevement/rejets.php
+++ b/htdocs/compta/prelevement/rejets.php
@@ -24,7 +24,7 @@
* \brief Reject page
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@@ -120,5 +120,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php
index 20d213e820b..ab233a61be3 100644
--- a/htdocs/compta/prelevement/stats.php
+++ b/htdocs/compta/prelevement/stats.php
@@ -24,7 +24,7 @@
* \brief Page with statistics on withdrawals
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -225,7 +225,7 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index c9e32b9a97f..4d643536388 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2012-2014 Raphaël Dourseanud
- * Copyright (C) 2014-2106 Ferran Marcet
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2014 Florian Henry
+/* Copyright (C) 2002-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2012-2014 Raphaël Dourseanud
+ * Copyright (C) 2014-2106 Ferran Marcet
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -161,7 +162,7 @@ if ($modecompta=="CREANCES-DETTES")
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
if (! empty($conf->accounting->enabled)) $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
@@ -175,9 +176,8 @@ elseif ($modecompta=="RECETTES-DEPENSES")
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
if (! empty($conf->accounting->enabled)) $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
- $periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
+ $periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesResultInOut");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
@@ -188,8 +188,7 @@ elseif ($modecompta=="BOOKKEEPING")
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
- //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
$period.=' '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
@@ -1210,6 +1209,6 @@ if ($mysoc->tva_assuj != 'franchise') // Assujetti
print "";
print ' ';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php
index fbbc7a36eef..5fc58955b60 100644
--- a/htdocs/compta/resultat/index.php
+++ b/htdocs/compta/resultat/index.php
@@ -1,10 +1,11 @@
- * Copyright (C) 2004-2012 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2014-2016 Ferran Marcet
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2014 Florian Henry
+/* Copyright (C) 2003 Rodolphe Quiedeville
+ * Copyright (C) 2004-2012 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2014-2016 Ferran Marcet
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -124,7 +125,7 @@ if ($modecompta == 'CREANCES-DETTES')
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
if (! empty($conf->accounting->enabled)) $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesAmountWithTaxIncluded");
$description.=' '.$langs->trans("RulesResultDue");
@@ -138,7 +139,7 @@ else if ($modecompta=="RECETTES-DEPENSES") {
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
if (! empty($conf->accounting->enabled)) $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesAmountWithTaxIncluded");
$description.=' '.$langs->trans("RulesResultInOut");
@@ -151,7 +152,7 @@ else if ($modecompta=="BOOKKEEPING")
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesAmountOnInOutBookkeepingRecord");
$description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')';
@@ -1009,5 +1010,6 @@ print " \n";
print "";
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php
index 23c7e91b989..c4a6e2ec755 100644
--- a/htdocs/compta/resultat/result.php
+++ b/htdocs/compta/resultat/result.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2016 Alexandre Spangaro
- * Copyright (C) 2018 Laurent Destailleur
+/* Copyright (C) 2016-2017 Jamal Elbaz
+ * Copyright (C) 2016 Alexandre Spangaro
+ * Copyright (C) 2018 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -171,7 +172,7 @@ if ($modecompta=="CREANCES-DETTES")
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">',' ').')';
if (! empty($conf->accounting->enabled)) $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
//$periodlink=''.img_previous().' '.img_next().' ';
$description=$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
@@ -179,25 +180,24 @@ if ($modecompta=="CREANCES-DETTES")
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
-else if ($modecompta=="RECETTES-DEPENSES") {
+elseif ($modecompta=="RECETTES-DEPENSES") {
$name=$langs->trans("AnnualByAccountInputOutputMode");
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">',' ').')';
if (! empty($conf->accounting->enabled)) $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
//$periodlink=''.img_previous().' '.img_next().' ';
$description=$langs->trans("RulesResultInOut");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
-else if ($modecompta=="BOOKKEEPING")
+elseif ($modecompta=="BOOKKEEPING")
{
$name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups");
$calcmode=$langs->trans("CalcModeBookkeeping");
//$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
//$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
$period.=' '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink = $textprevyear . $textnextyear ;
@@ -247,12 +247,12 @@ if ($modecompta == 'CREANCES-DETTES')
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
-else if ($modecompta=="RECETTES-DEPENSES")
+elseif ($modecompta=="RECETTES-DEPENSES")
{
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
-else if ($modecompta=="BOOKKEEPING")
+elseif ($modecompta=="BOOKKEEPING")
{
// Get array of all report groups that are active
@@ -537,5 +537,6 @@ else if ($modecompta=="BOOKKEEPING")
print "";
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php
index 45fee127642..f50d940a51a 100644
--- a/htdocs/compta/salaries/card.php
+++ b/htdocs/compta/salaries/card.php
@@ -1,8 +1,9 @@
+/* Copyright (C) 2011-2018 Alexandre Spangaro
* Copyright (C) 2014 Laurent Destailleur
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Charlie BENKE
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,17 +30,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
+if (! empty($conf->projet->enabled))
+{
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array("compta","banks","bills","users","salaries","hrm"));
+if (! empty($conf->projet->enabled)) $langs->load("projects");
$id=GETPOST("id",'int');
$action=GETPOST('action','aZ09');
+$cancel= GETPOST('cancel', 'aZ09');
+$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int'));
// Security check
$socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'salaries', '', '', 'payment');
+$result = restrictedArea($user, 'salaries', '', '', '');
$object = new PaymentSalary($db);
@@ -52,20 +61,27 @@ $hookmanager->initHooks(array('salarycard','globalcard'));
* Actions
*/
-if ($_POST["cancel"] == $langs->trans("Cancel"))
+if ($cancel)
{
header("Location: index.php");
exit;
}
-if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
+// Link to a project
+if ($action == 'classin' && $user->rights->banque->modifier)
+{
+ $object->fetch($id);
+ $object->setProject(GETPOST('projectid'));
+}
+
+if ($action == 'add' && empty($cancel))
{
$error=0;
- $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
- $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
- $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
- $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
+ $datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int'));
+ $datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int'));
+ $datesp=dol_mktime(12,0,0, GETPOST("datespmonth",'int'), GETPOST("datespday",'int'), GETPOST("datespyear",'int'));
+ $dateep=dol_mktime(12,0,0, GETPOST("dateepmonth",'int'), GETPOST("dateepday",'int'), GETPOST("dateepyear",'int'));
if (empty($datev)) $datev=$datep;
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1);
@@ -82,6 +98,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$object->type_payment=($type_payment > 0 ? $type_payment : 0);
$object->num_payment=GETPOST("num_payment");
$object->fk_user_author=$user->id;
+ $object->fk_project= GETPOST('fk_project','int');
// Set user current salary as ref salaray for the payment
$fuser=new User($db);
@@ -187,6 +204,7 @@ if ($action == 'delete')
llxHeader("",$langs->trans("SalaryPayment"));
$form = new Form($db);
+if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
if ($id)
{
@@ -238,13 +256,13 @@ if ($action == 'create')
// Date payment
print '';
print fieldLabel('DatePayment','datep',1).' ';
- print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
+ print $form->selectDate((empty($datep)?-1:$datep), "datep", '', '', '', 'add', 1, 1);
print ' ';
// Date value for bank
print '';
print fieldLabel('DateValue','datev',0).' ';
- print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
+ print $form->selectDate((empty($datev)?-1:$datev), "datev", '', '', '', 'add', 1, 1);
print ' ';
// Employee
@@ -263,13 +281,13 @@ if ($action == 'create')
// Date start period
print '';
print fieldLabel('DateStartPeriod','datesp',1).' ';
- print $form->select_date($datesp,"datesp",'','','','add');
+ print $form->selectDate($datesp, "datesp", '', '', '', 'add');
print ' ';
// Date end period
print '';
print fieldLabel('DateEndPeriod','dateep',1).' ';
- print $form->select_date($dateep,"dateep",'','','','add');
+ print $form->selectDate($dateep, "dateep", '', '', '', 'add');
print ' ';
// Amount
@@ -278,6 +296,18 @@ if ($action == 'create')
print ' ';
print '';
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $formproject=new FormProjets($db);
+
+ print ''.$langs->trans("Project").' ';
+
+ $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1);
+
+ print ' ';
+ }
+
// Bank
if (! empty($conf->banque->enabled))
{
@@ -335,14 +365,46 @@ if ($id)
dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment');
- $linkback = ''.$langs->trans("BackToList").' ';
+ $linkback = ''.$langs->trans("BackToList").' ';
$morehtmlref='';
+ // Employee
$userstatic=new User($db);
$userstatic->fetch($object->fk_user);
-
$morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1);
+
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($user->rights->salaries->write)
+ {
+ if ($action != 'classify')
+ $morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='
';
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref.='
';
+ $morehtmlref.=$proj->ref;
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.='';
+ }
+ }
+ }
$morehtmlref.='
';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
@@ -425,8 +487,6 @@ if ($id)
print "";
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php
index 3a3f34b85b4..dc45c9a4fb0 100644
--- a/htdocs/compta/salaries/class/paymentsalary.class.php
+++ b/htdocs/compta/salaries/class/paymentsalary.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2014 Juanjo Menent
+/* Copyright (C) 2011-2018 Alexandre Spangaro
+ * Copyright (C) 2014 Juanjo Menent
*
* 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
@@ -17,9 +17,9 @@
*/
/**
- * \file htdocs/compta/salaries/class/paymentsalary.class.php
- * \ingroup salaries
- * \brief Class for salaries module payment
+ * \file htdocs/compta/salaries/class/paymentsalary.class.php
+ * \ingroup salaries
+ * \brief Class for salaries module payment
*/
// Put here all includes required by your class file
@@ -31,18 +31,40 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class PaymentSalary extends CommonObject
{
- public $element='payment_salary'; //!< Id that identify managed objects
- public $table_element='payment_salary'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='payment_salary';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='payment_salary';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='payment';
public $tms;
+
+ /**
+ * @var int User ID
+ */
public $fk_user;
+
public $datep;
public $datev;
public $amount;
+ public $fk_project;
public $type_payment;
public $num_payment;
- public $label;
+
+ /**
+ * @var string salary payments label
+ */
+ public $label;
+
public $datesp;
public $dateep;
public $fk_bank;
@@ -102,6 +124,7 @@ class PaymentSalary extends CommonObject
$sql.= " datep='".$this->db->idate($this->datep)."',";
$sql.= " datev='".$this->db->idate($this->datev)."',";
$sql.= " amount=".price2num($this->amount).",";
+ $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',";
$sql.= " fk_typepayment=".$this->fk_typepayment."',";
$sql.= " num_payment='".$this->db->escape($this->num_payment)."',";
$sql.= " label='".$this->db->escape($this->label)."',";
@@ -161,6 +184,7 @@ class PaymentSalary extends CommonObject
$sql.= " s.datep,";
$sql.= " s.datev,";
$sql.= " s.amount,";
+ $sql.= " s.fk_projet as fk_project,";
$sql.= " s.fk_typepayment,";
$sql.= " s.num_payment,";
$sql.= " s.label,";
@@ -186,25 +210,26 @@ class PaymentSalary extends CommonObject
{
$obj = $this->db->fetch_object($resql);
- $this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->tms = $this->db->jdate($obj->tms);
- $this->fk_user = $obj->fk_user;
- $this->datep = $this->db->jdate($obj->datep);
- $this->datev = $this->db->jdate($obj->datev);
- $this->amount = $obj->amount;
- $this->type_payement = $obj->fk_typepayment;
- $this->num_payment = $obj->num_payment;
- $this->label = $obj->label;
- $this->datesp = $this->db->jdate($obj->datesp);
- $this->dateep = $this->db->jdate($obj->dateep);
- $this->note = $obj->note;
- $this->fk_bank = $obj->fk_bank;
- $this->fk_user_author = $obj->fk_user_author;
- $this->fk_user_modif = $obj->fk_user_modif;
- $this->fk_account = $obj->fk_account;
- $this->fk_type = $obj->fk_type;
- $this->rappro = $obj->rappro;
+ $this->id = $obj->rowid;
+ $this->ref = $obj->rowid;
+ $this->tms = $this->db->jdate($obj->tms);
+ $this->fk_user = $obj->fk_user;
+ $this->datep = $this->db->jdate($obj->datep);
+ $this->datev = $this->db->jdate($obj->datev);
+ $this->amount = $obj->amount;
+ $this->fk_project = $obj->fk_project;
+ $this->type_payement = $obj->fk_typepayment;
+ $this->num_payment = $obj->num_payment;
+ $this->label = $obj->label;
+ $this->datesp = $this->db->jdate($obj->datesp);
+ $this->dateep = $this->db->jdate($obj->dateep);
+ $this->note = $obj->note;
+ $this->fk_bank = $obj->fk_bank;
+ $this->fk_user_author = $obj->fk_user_author;
+ $this->fk_user_modif = $obj->fk_user_modif;
+ $this->fk_account = $obj->fk_account;
+ $this->fk_type = $obj->fk_type;
+ $this->rappro = $obj->rappro;
}
$this->db->free($resql);
@@ -276,12 +301,12 @@ class PaymentSalary extends CommonObject
$this->fk_user_modif='';
}
- /**
- * Create in database
- *
- * @param User $user User that create
- * @return int <0 if KO, >0 if OK
- */
+ /**
+ * Create in database
+ *
+ * @param User $user User that create
+ * @return int <0 if KO, >0 if OK
+ */
function create($user)
{
global $conf,$langs;
@@ -331,6 +356,7 @@ class PaymentSalary extends CommonObject
$sql.= ", datep";
$sql.= ", datev";
$sql.= ", amount";
+ $sql.= ", fk_projet";
$sql.= ", salary";
$sql.= ", fk_typepayment";
$sql.= ", num_payment";
@@ -348,6 +374,7 @@ class PaymentSalary extends CommonObject
$sql.= ", '".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount;
+ $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0);
$sql.= ", ".($this->salary > 0 ? $this->salary : "null");
$sql.= ", ".$this->db->escape($this->type_payment);
$sql.= ", '".$this->db->escape($this->num_payment)."'";
@@ -467,6 +494,7 @@ class PaymentSalary extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update link between payment salary and line generate into llx_bank
*
@@ -475,6 +503,7 @@ class PaymentSalary extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -502,13 +531,11 @@ class PaymentSalary extends CommonObject
global $langs;
$result='';
- $label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
+ $label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
- $linkstart = '';
+ $linkstart = ' ';
$linkend=' ';
- $picto='payment';
-
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
@@ -566,6 +593,7 @@ class PaymentSalary extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -575,6 +603,7 @@ class PaymentSalary extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
@@ -615,5 +644,4 @@ class PaymentSalary extends CommonObject
}*/
return '';
}
-
}
diff --git a/htdocs/compta/salaries/class/salariesstats.class.php b/htdocs/compta/salaries/class/salariesstats.class.php
index 647dc27f4a5..82a8d094148 100644
--- a/htdocs/compta/salaries/class/salariesstats.class.php
+++ b/htdocs/compta/salaries/class/salariesstats.class.php
@@ -29,6 +29,9 @@ include_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php
*/
class SalariesStats extends Stats
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element;
var $socid;
diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php
index 99c34f60815..59ca8389193 100644
--- a/htdocs/compta/salaries/document.php
+++ b/htdocs/compta/salaries/document.php
@@ -44,8 +44,9 @@ $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
// Security check
+$socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'salaries', $id, '');
+$result = restrictedArea($user, 'salaries', '', '', '');
// Get parameters
@@ -90,7 +91,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), -1, 'payment');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -133,6 +134,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php
index 0b70275654f..a8a0b82e7d9 100644
--- a/htdocs/compta/salaries/index.php
+++ b/htdocs/compta/salaries/index.php
@@ -148,7 +148,7 @@ if ($result)
if ($optioncss != '') $param.='&optioncss='.$optioncss;
$newcardbutton='';
- if ($user->rights->salaries->payment->write)
+ if (! empty($user->rights->salaries->write))
{
$newcardbutton=''.$langs->trans('NewSalaryPayment').' ';
$newcardbutton.= ' ';
@@ -294,6 +294,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/salaries/info.php b/htdocs/compta/salaries/info.php
index 467abe3618c..d2f02f3dc8f 100644
--- a/htdocs/compta/salaries/info.php
+++ b/htdocs/compta/salaries/info.php
@@ -79,6 +79,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/salaries/stats/index.php b/htdocs/compta/salaries/stats/index.php
index 3e6fd56a266..d5e3e226615 100644
--- a/htdocs/compta/salaries/stats/index.php
+++ b/htdocs/compta/salaries/stats/index.php
@@ -41,18 +41,6 @@ $socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', '', '', '');
-// Other security check
-$childids = $user->getAllChildIds();
-$childids[]=$user->id;
-if ($userid > 0)
-{
- if (empty($user->rights->salaries->payment->readall) && ! in_array($userid, $childids))
- {
- accessforbidden();
- exit;
- }
-}
-
$nowyear=strftime("%Y", dol_now());
$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
//$startyear=$year-2;
@@ -77,11 +65,6 @@ print load_fiche_titre($title, $mesg);
dol_mkdir($dir);
$useridtofilter=$userid; // Filter from parameters
-if (empty($useridtofilter))
-{
- $useridtofilter=$childids;
- if (! empty($user->rights->salaries->payment->readall)) $useridtofilter=0;
-}
$stats = new SalariesStats($db, $socid, $useridtofilter);
@@ -288,7 +271,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index 85e555de468..4ffa1a2829f 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -1,8 +1,8 @@
- * Copyright (C) 2005-2013 Regis Houssin
- * Copyright (C) 2016 Frédéric France
- * Copyright (C) 2017 Alexandre Spangaro
+/* Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2013 Regis Houssin
+ * Copyright (C) 2016-2018 Frédéric France
+ * Copyright (C) 2017 Alexandre Spangaro
*
* 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
@@ -29,17 +29,18 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($conf->projet->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
if (! empty($conf->accounting->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page
-$langs->loadLangs(array('compta', 'bills'));
+$langs->loadLangs(array('compta', 'bills', 'banks'));
$id=GETPOST('id','int');
$action=GETPOST('action','aZ09');
@@ -241,11 +242,12 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
{
$object->paye = 0;
$object->id = $object->ref = null;
+ $object->lib = $langs->trans("CopyOf").' '.$object->lib;
- if(GETPOST('clone_for_next_month') != '') {
-
- $object->date_ech = strtotime('+1month', $object->date_ech);
- $object->periode = strtotime('+1month', $object->periode);
+ if (GETPOST('clone_for_next_month') != '')
+ {
+ $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
+ $object->periode = dol_time_plus_duree($object->periode, 1, 'm');
}
if ($object->check())
@@ -330,7 +332,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo"));
print '';
print '';
- print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
+ print $form->selectDate(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
print ' ';
print '';
@@ -340,7 +342,7 @@ if ($action == 'create')
print $langs->trans("DateDue");
print '';
print '';
- print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
+ print $form->selectDate(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
print ' ';
print "\n";
@@ -500,7 +502,7 @@ if ($id > 0)
print "";
if ($action == 'edit')
{
- print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1);
+ print $form->selectDate($object->periode, 'period', 0, 0, 0, 'charge', 1);
}
else
{
@@ -512,10 +514,9 @@ if ($id > 0)
if ($action == 'edit')
{
print ' '.$langs->trans("DateDue")." ";
- print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
+ print $form->selectDate($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
print " ";
- }
- else {
+ } else {
print "".$langs->trans("DateDue")." ".dol_print_date($object->date_ech,'day')." ";
}
@@ -748,7 +749,6 @@ if ($id > 0)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php
index a44b820c8ea..409ee99aaae 100644
--- a/htdocs/compta/sociales/class/cchargesociales.class.php
+++ b/htdocs/compta/sociales/class/cchargesociales.class.php
@@ -38,14 +38,12 @@ class Cchargesociales
* @var string Id to identify managed objects
*/
public $element = 'cchargesociales';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'c_chargesociales';
- /**
- */
-
public $libelle;
public $deductible;
public $active;
@@ -54,9 +52,6 @@ class Cchargesociales
public $module;
public $accountancy_code;
- /**
- */
-
/**
* Constructor
@@ -83,7 +78,7 @@ class Cchargesociales
$error = 0;
// Clean parameters
-
+
if (isset($this->libelle)) {
$this->libelle = trim($this->libelle);
}
@@ -106,14 +101,14 @@ class Cchargesociales
$this->accountancy_code = trim($this->accountancy_code);
}
-
+
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
-
+
$sql.= 'libelle,';
$sql.= 'deductible,';
$sql.= 'active,';
@@ -122,9 +117,9 @@ class Cchargesociales
$sql.= 'module';
$sql.= 'accountancy_code';
-
+
$sql .= ') VALUES (';
-
+
$sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").',';
$sql .= ' '.(! isset($this->deductible)?'NULL':$this->deductible).',';
$sql .= ' '.(! isset($this->active)?'NULL':$this->active).',';
@@ -133,7 +128,7 @@ class Cchargesociales
$sql .= ' '.(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'").',';
$sql .= ' '.(! isset($this->accountancy_code)?'NULL':"'".$this->db->escape($this->accountancy_code)."'");
-
+
$sql .= ')';
$this->db->begin();
@@ -206,7 +201,7 @@ class Cchargesociales
$obj = $this->db->fetch_object($resql);
$this->id = $obj->id;
-
+
$this->libelle = $obj->libelle;
$this->deductible = $obj->deductible;
$this->active = $obj->active;
@@ -215,7 +210,7 @@ class Cchargesociales
$this->module = $obj->module;
$this->accountancy_code = $obj->accountancy_code;
-
+
}
$this->db->free($resql);
@@ -247,7 +242,7 @@ class Cchargesociales
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
-
+
if (isset($this->libelle)) {
$this->libelle = trim($this->libelle);
}
@@ -270,7 +265,7 @@ class Cchargesociales
$this->accountancy_code = trim($this->accountancy_code);
}
-
+
// Check parameters
// Put here code to add a control on parameters values
@@ -454,7 +449,7 @@ class Cchargesociales
$result.= $link . $this->ref . $linkend;
return $result;
}
-
+
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
@@ -466,6 +461,7 @@ class Cchargesociales
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un status donne
*
@@ -475,6 +471,7 @@ class Cchargesociales
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
@@ -509,8 +506,8 @@ class Cchargesociales
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
-
-
+
+
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
@@ -520,7 +517,7 @@ class Cchargesociales
public function initAsSpecimen()
{
$this->id = 0;
-
+
$this->libelle = '';
$this->deductible = '';
$this->active = '';
@@ -528,8 +525,5 @@ class Cchargesociales
$this->fk_pays = '';
$this->module = '';
$this->accountancy_code = '';
-
-
}
-
}
diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php
index 65e6085a650..2ea82fb32c4 100644
--- a/htdocs/compta/sociales/class/chargesociales.class.php
+++ b/htdocs/compta/sociales/class/chargesociales.class.php
@@ -32,9 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class ChargeSociales extends CommonObject
{
- public $element='chargesociales';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='chargesociales';
+
public $table='chargesociales';
- public $table_element='chargesociales';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='chargesociales';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'bill';
/**
@@ -42,18 +54,18 @@ class ChargeSociales extends CommonObject
*/
protected $table_ref_field = 'ref';
- var $date_ech;
- var $lib;
- var $type;
- var $type_libelle;
- var $amount;
- var $paye;
- var $periode;
- var $date_creation;
- var $date_modification;
- var $date_validation;
- var $fk_account;
- var $fk_project;
+ public $date_ech;
+ public $lib;
+ public $type;
+ public $type_libelle;
+ public $amount;
+ public $paye;
+ public $periode;
+ public $date_creation;
+ public $date_modification;
+ public $date_validation;
+ public $fk_account;
+ public $fk_project;
/**
@@ -280,7 +292,6 @@ class ChargeSociales extends CommonObject
$this->db->rollback();
return -1;
}
-
}
@@ -359,6 +370,7 @@ class ChargeSociales extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag social contribution as payed completely
*
@@ -367,6 +379,7 @@ class ChargeSociales extends CommonObject
*/
function set_paid($user)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET";
$sql.= " paye = 1";
$sql.= " WHERE rowid = ".$this->id;
@@ -374,6 +387,8 @@ class ChargeSociales extends CommonObject
if ($return) return 1;
else return -1;
}
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Remove tag payed on social contribution
*
@@ -382,6 +397,7 @@ class ChargeSociales extends CommonObject
*/
function set_unpaid($user)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET";
$sql.= " paye = 0";
$sql.= " WHERE rowid = ".$this->id;
@@ -402,6 +418,7 @@ class ChargeSociales extends CommonObject
return $this->LibStatut($this->paye,$mode,$alreadypaid);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -412,52 +429,48 @@ class ChargeSociales extends CommonObject
*/
function LibStatut($statut,$mode=0,$alreadypaid=-1)
{
+ // phpcs:enable
global $langs;
$langs->load('customers');
$langs->load('bills');
- if ($mode == 0)
+ if ($mode == 0 || $mode == 1)
{
if ($statut == 0) return $langs->trans("Unpaid");
if ($statut == 1) return $langs->trans("Paid");
}
- if ($mode == 1)
- {
- if ($statut == 0) return $langs->trans("Unpaid");
- if ($statut == 1) return $langs->trans("Paid");
- }
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
- return "Error, mode/status not found";
+ else return "Error, mode/status not found";
}
@@ -637,4 +650,3 @@ class ChargeSociales extends CommonObject
$this->type_libelle = 'Social contribution label';
}
}
-
diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
index ba9c671f755..442e63efe11 100644
--- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
+++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
@@ -31,26 +31,39 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
*/
class PaymentSocialContribution extends CommonObject
{
- public $element='paiementcharge'; //!< Id that identify managed objects
- public $table_element='paiementcharge'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='paiementcharge';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='paiementcharge';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'payment';
- var $fk_charge;
- var $datec='';
- var $tms='';
- var $datep='';
+ public $fk_charge;
+ public $datec='';
+ public $tms='';
+ public $datep='';
+
/**
* @deprecated
* @see amount
*/
- var $total;
- var $amount; // Total amount of payment
- var $amounts=array(); // Array of amounts
- var $fk_typepaiement;
- var $num_paiement;
- var $fk_bank;
- var $fk_user_creat;
- var $fk_user_modif;
+ public $total;
+
+ public $amount; // Total amount of payment
+ public $amounts=array(); // Array of amounts
+ public $fk_typepaiement;
+ public $num_paiement;
+ public $fk_bank;
+ public $fk_user_creat;
+ public $fk_user_modif;
/**
* Constructor
@@ -493,8 +506,6 @@ class PaymentSocialContribution extends CommonObject
$this->fk_bank='';
$this->fk_user_creat='';
$this->fk_user_modif='';
-
-
}
@@ -518,7 +529,7 @@ class PaymentSocialContribution extends CommonObject
if (! empty($conf->banque->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$acc->fetch($accountid);
@@ -594,6 +605,7 @@ class PaymentSocialContribution extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee
*
@@ -602,6 +614,7 @@ class PaymentSocialContribution extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
@@ -629,6 +642,7 @@ class PaymentSocialContribution extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -638,6 +652,7 @@ class PaymentSocialContribution extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
@@ -708,5 +723,3 @@ class PaymentSocialContribution extends CommonObject
return $result;
}
}
-
-
diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php
index 490dbf3a1fe..b2f73768e96 100644
--- a/htdocs/compta/sociales/document.php
+++ b/htdocs/compta/sociales/document.php
@@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (! empty($conf->projet->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
// Load translation files required by the page
@@ -76,7 +76,7 @@ $modulepart='tax';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
if ($action == 'setlib' && $user->rights->tax->charges->creer)
{
@@ -136,7 +136,7 @@ if ($object->id)
print '';
print '
';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -168,7 +168,6 @@ else
print $langs->trans("ErrorUnknown");
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php
index bd323c972fe..6a0250804f1 100644
--- a/htdocs/compta/sociales/index.php
+++ b/htdocs/compta/sociales/index.php
@@ -304,5 +304,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php
index 1827c1597f8..bd21db108c1 100644
--- a/htdocs/compta/sociales/info.php
+++ b/htdocs/compta/sociales/info.php
@@ -27,8 +27,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (! empty($conf->projet->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
// Load translation files required by the page
@@ -115,6 +115,6 @@ print '';
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php
index 3b7f68f8c83..48b2698c762 100644
--- a/htdocs/compta/sociales/payments.php
+++ b/htdocs/compta/sociales/payments.php
@@ -397,7 +397,7 @@ while($j<$numlt)
// Payment Salary
-if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
+if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
{
if (! $mode || $mode != 'sconly')
{
@@ -480,7 +480,6 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php
index 78a9187be57..5c9366037ed 100644
--- a/htdocs/compta/stats/byratecountry.php
+++ b/htdocs/compta/stats/byratecountry.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2018 Laurent Destailleur
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -152,7 +153,7 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start; $prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
@@ -190,13 +191,15 @@ $namesup=$namecust;
+// TODO Report from bookkeeping not yet available, so we switch on report on business events
+if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES";
+if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES";
// Show report header
-$name=$langs->trans("SalesTurnover").', '.$langs->trans("ByVatRate");
-
if ($modecompta=="CREANCES-DETTES") {
+ $name=$langs->trans("Turnover").', '.$langs->trans("ByVatRate");
$calcmode=$langs->trans("CalcModeDebt");
- $calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
@@ -206,16 +209,29 @@ if ($modecompta=="CREANCES-DETTES") {
}
$builddate=dol_now();
-} else {
+}
+else if ($modecompta=="RECETTES-DEPENSES")
+{
+ $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate");
$calcmode=$langs->trans("CalcModeEngagement");
- $calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+else if ($modecompta=="BOOKKEEPING")
+{
+
+
+}
+else if ($modecompta=="BOOKKEEPINGCOLLECTED")
+{
+
+
+}
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().' ';
else $periodlink = '';
@@ -399,7 +415,6 @@ print "\n";
print ' '.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . ' ';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
index 5c2a50325a7..e7a3d4da480 100644
--- a/htdocs/compta/stats/cabyprodserv.php
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2013-2016 Laurent Destailleur
- * Copyright (C) 2015 Raphaël Doursenaud
+/* Copyright (C) 2013 Antoine Iauch
+ * Copyright (C) 2013-2016 Laurent Destailleur
+ * Copyright (C) 2015 Raphaël Doursenaud
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -158,12 +159,15 @@ llxHeader();
$form=new Form($db);
$formother = new FormOther($db);
-// Show report header
-$name=$langs->trans("SalesTurnover").', '.$langs->trans("ByProductsAndServices");
+// TODO Report from bookkeeping not yet available, so we switch on report on business events
+if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES";
+if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES";
+// Show report header
if ($modecompta=="CREANCES-DETTES") {
+ $name=$langs->trans("Turnover").', '.$langs->trans("ByProductsAndServices");
$calcmode=$langs->trans("CalcModeDebt");
- $calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
@@ -173,16 +177,30 @@ if ($modecompta=="CREANCES-DETTES") {
}
$builddate=dol_now();
-} else {
+}
+else if ($modecompta=="RECETTES-DEPENSES")
+{
+ $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices");
$calcmode=$langs->trans("CalcModeEngagement");
- $calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+else if ($modecompta=="BOOKKEEPING")
+{
+
+
+}
+else if ($modecompta=="BOOKKEEPINGCOLLECTED")
+{
+
+
+}
+
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().' ';
else $periodlink = '';
@@ -444,5 +462,6 @@ if ($modecompta == 'CREANCES-DETTES')
print ' '.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . ' ';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php
index dbd5d46e61a..4f49b9492ff 100644
--- a/htdocs/compta/stats/cabyuser.php
+++ b/htdocs/compta/stats/cabyuser.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2013 Antoine Iauch
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2013 Antoine Iauch
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -142,26 +143,42 @@ llxHeader();
$form=new Form($db);
+// TODO Report from bookkeeping not yet available, so we switch on report on business events
+if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES";
+if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES";
+
// Show report header
if ($modecompta=="CREANCES-DETTES") {
- $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
+ $name=$langs->trans("Turnover").', '.$langs->trans("ByUserAuthorOfInvoice");
$calcmode=$langs->trans("CalcModeDebt");
- $calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
-} else {
- $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
+}
+else if ($modecompta=="RECETTES-DEPENSES")
+{
+ $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByUserAuthorOfInvoice");
$calcmode=$langs->trans("CalcModeEngagement");
- $calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+else if ($modecompta=="BOOKKEEPING")
+{
+
+
+}
+else if ($modecompta=="BOOKKEEPINGCOLLECTED")
+{
+
+
+}
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().' ';
else $periodlink = '';
@@ -327,7 +344,7 @@ print_liste_field_titre(
"",
'align="center" width="20%"'
);
-print "\n";
+print "\n";
if (count($amount)) {
$arrayforsort=$name;
@@ -449,7 +466,6 @@ print "";
print '';
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index 1555b3c79ac..309737111f5 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -5,6 +5,7 @@
* Copyright (C) 2007 Franky Van Liedekerke
* Copyright (C) 2013 Antoine Iauch
* Copyright (C) 2015 Raphaël Doursenaud
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -167,27 +168,43 @@ $form=new Form($db);
$thirdparty_static=new Societe($db);
$formother = new FormOther($db);
+// TODO Report from bookkeeping not yet available, so we switch on report on business events
+if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES";
+if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES";
+
// Show report header
if ($modecompta=="CREANCES-DETTES")
{
- $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties");
+ $name=$langs->trans("Turnover").', '.$langs->trans("ByThirdParties");
$calcmode=$langs->trans("CalcModeDebt");
- $calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
-} else {
- $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties");
+}
+else if ($modecompta=="RECETTES-DEPENSES")
+{
+ $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByThirdParties");
$calcmode=$langs->trans("CalcModeEngagement");
- $calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+else if ($modecompta=="BOOKKEEPING")
+{
+
+
+}
+else if ($modecompta=="BOOKKEEPINGCOLLECTED")
+{
+
+
+}
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().' ';
else $periodlink = '';
@@ -230,8 +247,8 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql.=" AND cs.fk_soc is null";
}
else if ($selected_cat) { // Into a specific category
- $sql.= " AND (c.rowid = ".$selected_cat;
- if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
+ $sql.= " AND (c.rowid = ".$db->escape($selected_cat);
+ if ($subcat) $sql.=" OR c.fk_parent = " . $db->escape($selected_cat);
$sql.= ")";
$sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
@@ -270,10 +287,10 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
}
-if(!empty($search_societe)) $sql.= ' AND s.nom LIKE "%'.$search_societe.'%"';
-if(!empty($search_zip)) $sql.= ' AND s.zip LIKE "%'.$search_zip.'%"';
-if(!empty($search_town)) $sql.= ' AND s.town LIKE "%'.$search_town.'%"';
-if($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.'';
+if (!empty($search_societe)) $sql.= natural_search('s.nom', $search_societe);
+if (!empty($search_zip)) $sql.= natural_search('s.zip', $search_zip);
+if (!empty($search_town)) $sql.= natural_search('s.town', $search_town);
+if ($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.'';
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
@@ -630,6 +647,6 @@ print "";
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index dd24a6cd507..c5ceccdad61 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2004-2012 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2017 Olivier Geffroy
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2012 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2017 Olivier Geffroy
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -115,11 +116,11 @@ $form=new Form($db);
// Affiche en-tete du rapport
if ($modecompta=="CREANCES-DETTES")
{
- $name=$langs->trans("SalesTurnover");
+ $name=$langs->trans("Turnover");
$calcmode=$langs->trans("CalcModeDebt");
- $calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
@@ -129,11 +130,11 @@ if ($modecompta=="CREANCES-DETTES")
}
else if ($modecompta=="RECETTES-DEPENSES")
{
- $name=$langs->trans("SalesTurnover");
+ $name=$langs->trans("TurnoverCollected");
$calcmode=$langs->trans("CalcModeEngagement");
- $calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
- $calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ //$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
+ //$calcmode.=' ('.$langs->trans("SeeReportInBookkeepingMode",'',' ').')';
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
@@ -142,11 +143,11 @@ else if ($modecompta=="RECETTES-DEPENSES")
}
else if ($modecompta=="BOOKKEEPING")
{
- $name=$langs->trans("SalesTurnover");
+ $name=$langs->trans("Turnover");
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
- $calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ //$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()." ":"");
$description=$langs->trans("RulesCATotalSaleJournal");
$builddate=dol_now();
@@ -629,6 +630,6 @@ print '';
*/
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php
index 4480682b091..69483d84be0 100644
--- a/htdocs/compta/tva/card.php
+++ b/htdocs/compta/tva/card.php
@@ -3,6 +3,7 @@
* Copyright (C) 2004-2016 Laurent Destailleur
* Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2015-2017 Alexandre Spangaro
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -255,11 +256,11 @@ if ($action == 'create')
print "";
print ''.$langs->trans("DatePayment").' ';
- print $form->select_date($datep,"datep",'','','','add',1,1);
+ print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print ' ';
print ''.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).' ';
- print $form->select_date($datev,"datev",'','','','add',1,1);
+ print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1);
print ' ';
// Label
diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php
index af330910cdf..8b407c9be61 100644
--- a/htdocs/compta/tva/class/tva.class.php
+++ b/htdocs/compta/tva/class/tva.class.php
@@ -33,20 +33,36 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Tva extends CommonObject
{
- public $element='tva'; //!< Id that identify managed objects
- public $table_element='tva'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='tva';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='tva';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='payment';
- var $tms;
- var $datep;
- var $datev;
- var $amount;
- var $type_payment;
- var $num_payment;
- var $label;
- var $fk_bank;
- var $fk_user_creat;
- var $fk_user_modif;
+ public $tms;
+ public $datep;
+ public $datev;
+ public $amount;
+ public $type_payment;
+ public $num_payment;
+
+ /**
+ * @var string label
+ */
+ public $label;
+
+ public $fk_bank;
+ public $fk_user_creat;
+ public $fk_user_modif;
/**
* Constructor
@@ -350,14 +366,16 @@ class Tva extends CommonObject
return $solde;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Total of the VAT from invoices emitted by the thirdparty.
*
* @param int $year Year
- * @return double Amount
+ * @return double Amount
*/
function tva_sum_collectee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.tva) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
@@ -389,6 +407,7 @@ class Tva extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* VAT payed
*
@@ -397,6 +416,7 @@ class Tva extends CommonObject
*/
function tva_sum_payee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.total_tva) as total_tva";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
@@ -429,6 +449,7 @@ class Tva extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Total of the VAT payed
*
@@ -437,6 +458,7 @@ class Tva extends CommonObject
*/
function tva_sum_reglee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
@@ -620,6 +642,7 @@ class Tva extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update link between payment tva and line generate into llx_bank
*
@@ -628,6 +651,7 @@ class Tva extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -783,6 +807,7 @@ class Tva extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -790,10 +815,11 @@ class Tva extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
- function LibStatut($status,$mode=0)
- {
- global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
+ function LibStatut($status,$mode=0)
+ {
+ // phpcs:enable
+ global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
- return '';
- }
+ return '';
+ }
}
diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php
index ae95d71ca9c..74a08d0d142 100644
--- a/htdocs/compta/tva/clients.php
+++ b/htdocs/compta/tva/clients.php
@@ -3,7 +3,8 @@
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2006 Yannick Warnier
- * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -136,18 +137,22 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
-$prevyear=$year_start; $prevquarter=$q;
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
+$prevyear=$year_start;
+$prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
- $prevquarter=4; $prevyear--;
+ $prevquarter=4;
+ $prevyear--;
}
-$nextyear=$year_start; $nextquarter=$q;
+$nextyear=$year_start;
+$nextquarter=$q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
- $nextquarter=1; $nextyear++;
+ $nextquarter=1;
+ $nextyear++;
}
$builddate=dol_now();
diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php
index b83cad80bdd..790058c20a9 100644
--- a/htdocs/compta/tva/document.php
+++ b/htdocs/compta/tva/document.php
@@ -122,7 +122,7 @@ if ($object->id)
print '';
print '
';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php
index 7c4912411f6..8e4fccf4168 100644
--- a/htdocs/compta/tva/index.php
+++ b/htdocs/compta/tva/index.php
@@ -4,6 +4,7 @@
* Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -217,7 +218,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.=' '.$langs->trans("ThisIsAnEstimatedValue");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$builddate=dol_now();
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index e2c7cc5d793..ff3e3ce127d 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2013 Laurent Destailleur
- * Copyright (C) 2006-2007, 2015 Yannick Warnier
- * Copyright (C) 2014 Ferran Marcet
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2006-2015 Yannick Warnier
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -135,18 +136,21 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start; $prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
- $prevquarter=4; $prevyear--;
+ $prevquarter=4;
+ $prevyear--;
}
-$nextyear=$year_start; $nextquarter=$q;
+$nextyear=$year_start;
+$nextquarter=$q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
- $nextquarter=1; $nextyear++;
+ $nextquarter=1;
+ $nextyear++;
}
$description.=$fsearch;
$builddate=dol_now();
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 7475cf54ddb..886a6171818 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -14,7 +14,7 @@
// dolibarr_main_url_root
// This parameter defines the root URL of your Dolibarr index.php page without ending "/".
// It must link to the directory htdocs.
-// In most cases, this is autodetected but it's still required
+// In most cases, this is autodetected but it's still required
// * to show full url bookmarks for some services (ie: agenda rss export url, ...)
// * or when using Apache dir aliases (autodetect fails)
// * or when using nginx (autodetect fails)
@@ -40,7 +40,7 @@ $dolibarr_main_document_root='';
// dolibarr_main_url_root_alt
// This parameter defines the relative sub URLs to add to $dolibarr_main_url_root to
// forge alternative root directories (used by modules developers).
-// You can put several values, separated by a coma, but number of entries must match
+// You can put several values, separated by a coma, but number of entries must match
// number of entries into $dolibarr_main_document_root_alt.
// Examples:
// $dolibarr_main_url_root_alt='/custom';
@@ -52,7 +52,7 @@ $dolibarr_main_document_root='';
// dolibarr_main_document_root_alt
// This parameter contains absolute alternative root file system directories (used by
// modules developers).
-// You can put several values, separated by a coma, but number of entries must match
+// You can put several values, separated by a coma, but number of entries must match
// number of entries into $dolibarr_main_url_root_alt.
// Examples:
// $dolibarr_main_document_root_alt='/var/www/dolibarr/htdocs/custom';
@@ -162,7 +162,7 @@ $dolibarr_main_db_collation='utf8_unicode_ci';
// Default value: dolibarr
// Possible values: Any values found in files in htdocs/core/login directory after
// the "function_" string and before the ".php" string. You can also separate several
-// values using a ",". In this case, Dolibarr will check login/pass for each value in
+// values using a ",". In this case, Dolibarr will check login/pass for each value in
// order defined into value. However, note that this can't work with all values.
// Examples:
// $dolibarr_main_authentication='http';
@@ -207,10 +207,10 @@ $dolibarr_main_authentication='dolibarr';
// 0 = No forced redirect
// 1 = Force redirect to https, until SCRIPT_URI start with https into response
// 2 = Force redirect to https, until SERVER["HTTPS"] is 'on' into response
-// 'https://my.domain.com' = Force reditect to https using this domain name.
+// 'https://my.domain.com' = Force reditect to https using this domain name.
// Warning: If you enable this parameter, your web server must be configured to
-// respond URL with https protocol.
-// According to your web server setup, some values may works and other not. Try
+// respond URL with https protocol.
+// According to your web server setup, some values may works and other not. Try
// different values (1,2 or 'https://my.domain.com') if you experience problems.
// Default value: 0
// Possible values: 0, 1, 2 or 'https://my.domain.com'
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index ba96c865d1a..7e413854846 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -27,7 +27,11 @@
*/
abstract class ActionsContactCardCommon
{
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $dirmodule;
var $targetmodule;
var $canvas;
@@ -37,10 +41,17 @@ abstract class ActionsContactCardCommon
var $tpl = array();
//! Object container
var $object;
- //! Error string
- var $error;
- //! Error array
- var $errors=array();
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
/**
@@ -65,7 +76,8 @@ abstract class ActionsContactCardCommon
//}
}
- /**
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
* Set content of ->tpl array, to use into template
*
* @param string $action Type of action
@@ -74,6 +86,7 @@ abstract class ActionsContactCardCommon
*/
function assign_values(&$action, $id)
{
+ // phpcs:enable
global $conf, $langs, $user, $canvas;
global $form, $formcompany, $objsoc;
@@ -254,6 +267,7 @@ abstract class ActionsContactCardCommon
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Assign POST values into object
*
@@ -261,31 +275,32 @@ abstract class ActionsContactCardCommon
*/
private function assign_post()
{
+ // phpcs:enable
global $langs, $mysoc;
- $this->object->old_name = $_POST["old_name"];
- $this->object->old_firstname = $_POST["old_firstname"];
+ $this->object->old_name = $_POST["old_name"];
+ $this->object->old_firstname = $_POST["old_firstname"];
- $this->object->socid = $_POST["socid"];
- $this->object->lastname = $_POST["name"];
- $this->object->firstname = $_POST["firstname"];
- $this->object->civility_id = $_POST["civility_id"];
- $this->object->poste = $_POST["poste"];
- $this->object->address = $_POST["address"];
- $this->object->zip = $_POST["zipcode"];
- $this->object->town = $_POST["town"];
- $this->object->fk_departement = $_POST["state_id"];
- $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
- $this->object->state_id = $_POST["state_id"];
- $this->object->phone_pro = $_POST["phone_pro"];
- $this->object->phone_perso = $_POST["phone_perso"];
- $this->object->phone_mobile = $_POST["phone_mobile"];
- $this->object->fax = $_POST["fax"];
- $this->object->email = $_POST["email"];
- $this->object->jabberid = $_POST["jabberid"];
- $this->object->priv = $_POST["priv"];
- $this->object->note = $_POST["note"];
- $this->object->canvas = $_POST["canvas"];
+ $this->object->socid = $_POST["socid"];
+ $this->object->lastname = $_POST["name"];
+ $this->object->firstname = $_POST["firstname"];
+ $this->object->civility_id = $_POST["civility_id"];
+ $this->object->poste = $_POST["poste"];
+ $this->object->address = $_POST["address"];
+ $this->object->zip = $_POST["zipcode"];
+ $this->object->town = $_POST["town"];
+ $this->object->fk_departement = $_POST["state_id"];
+ $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
+ $this->object->state_id = $_POST["state_id"];
+ $this->object->phone_pro = $_POST["phone_pro"];
+ $this->object->phone_perso = $_POST["phone_perso"];
+ $this->object->phone_mobile = $_POST["phone_mobile"];
+ $this->object->fax = $_POST["fax"];
+ $this->object->email = $_POST["email"];
+ $this->object->jabberid = $_POST["jabberid"];
+ $this->object->priv = $_POST["priv"];
+ $this->object->note = $_POST["note"];
+ $this->object->canvas = $_POST["canvas"];
// We set country_id, and country_code label of the chosen country
if ($this->object->country_id)
@@ -305,6 +320,4 @@ abstract class ActionsContactCardCommon
$this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
}
}
-
}
-
diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
index bfcb5a21142..5831b943d76 100644
--- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php
+++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
@@ -29,8 +29,8 @@ include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class
*/
class ActionsContactCardDefault extends ActionsContactCardCommon
{
- /**
- * Constructor
+ /**
+ * Constructor
*
* @param DoliDB $db Handler acces base de donnees
* @param string $dirmodule Name of directory of module
@@ -66,6 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Assign custom values for canvas
*
@@ -75,6 +76,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
function assign_values(&$action, $id)
{
+ // phpcs:enable
global $limit, $offset, $sortfield, $sortorder;
global $conf, $db, $langs, $user;
global $form;
@@ -116,10 +118,10 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
{
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
@@ -131,6 +133,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
+ // phpcs:enable
global $conf, $langs;
//$this->getFieldList();
@@ -138,4 +141,3 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->list_datas = array();
}
}
-
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 52957d25343..9e1757fdc5a 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -1,13 +1,14 @@
- * Copyright (C) 2004-2015 Laurent Destailleur
- * Copyright (C) 2004 Benoit Mortier
- * Copyright (C) 2005-2017 Regis Houssin
- * Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2013 Florian Henry
- * Copyright (C) 2013-2016 Alexandre Spangaro
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2015 Jean-François Ferry
+/* Copyright (C) 2004-2005 Rodolphe Quiedeville
+ * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2004 Benoit Mortier
+ * Copyright (C) 2005-2017 Regis Houssin
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013-2016 Alexandre Spangaro
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -704,11 +705,11 @@ else
$form=new Form($db);
if ($object->birthday)
{
- print $form->select_date($object->birthday,'birthday',0,0,0,"perso", 1, 0, 1);
+ print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0);
}
else
{
- print $form->select_date('','birthday',0,0,1,"perso", 1, 0, 1);
+ print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0);
}
print '';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 4724f0d97cd..f81c4eed4c3 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -37,9 +37,21 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Contact extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='contact';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='socpeople';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'contact';
@@ -123,9 +135,6 @@ class Contact extends CommonObject
public $oldcopy; // To contains a clone of this when we need to save old properties of object
-
-
-
/**
* Constructor
*
@@ -137,6 +146,7 @@ class Contact extends CommonObject
$this->statut = 1; // By default, status is enabled
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators into this->nb for board
*
@@ -144,6 +154,7 @@ class Contact extends CommonObject
*/
function load_state_board()
{
+ // phpcs:enable
global $user;
$this->nb=array();
@@ -204,7 +215,7 @@ class Contact extends CommonObject
if (empty($this->priv)) $this->priv = 0;
if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
- $entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
+ $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (";
$sql.= " datec";
@@ -228,7 +239,7 @@ class Contact extends CommonObject
$sql.= " ".$this->db->escape($this->priv).",";
$sql.= " ".$this->db->escape($this->statut).",";
$sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").",";
- $sql.= " ".$this->db->escape($entity).",";
+ $sql.= " ".$this->db->escape($this->entity).",";
$sql.= "'".$this->db->escape($this->ref_ext)."',";
$sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
$sql.= ")";
@@ -307,6 +318,8 @@ class Contact extends CommonObject
$this->id = $id;
+ $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
+
// Clean parameters
$this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->lastname);
$this->firstname=trim($this->firstname);
@@ -354,6 +367,7 @@ class Contact extends CommonObject
$sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL");
$sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL");
$sql .= ", no_email=".($this->no_email?"'".$this->db->escape($this->no_email)."'":"0");
+ $sql .= ", entity = " . $this->db->escape($this->entity);
$sql .= " WHERE rowid=".$this->db->escape($id);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@@ -368,15 +382,12 @@ class Contact extends CommonObject
$action='update';
// Actions on extra fields
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- $result=$this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ $error++;
}
}
@@ -466,6 +477,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
@@ -477,6 +489,7 @@ class Contact extends CommonObject
*/
function _load_ldap_dn($info,$mode=0)
{
+ // phpcs:enable
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
@@ -486,6 +499,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Initialise tableau info (tableau des attributs LDAP)
*
@@ -493,6 +507,7 @@ class Contact extends CommonObject
*/
function _load_ldap_info()
{
+ // phpcs:enable
global $conf,$langs;
$info = array();
@@ -559,6 +574,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update field alert birthday
*
@@ -569,6 +585,7 @@ class Contact extends CommonObject
*/
function update_perso($id, $user=null, $notrigger=0)
{
+ // phpcs:enable
$error=0;
$result=false;
@@ -677,6 +694,7 @@ class Contact extends CommonObject
$sql.= " c.photo,";
$sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,";
$sql.= " c.import_key,";
+ $sql.= " c.datec as date_creation, c.tms as date_modification,";
$sql.= " co.label as country, co.code as country_code,";
$sql.= " d.nom as state, d.code_departement as state_code,";
$sql.= " u.rowid as user_id, u.login as user_login,";
@@ -711,6 +729,9 @@ class Contact extends CommonObject
$this->zip = $obj->zip;
$this->town = $obj->town;
+ $this->date_creation = $this->db->jdate($obj->date_creation);
+ $this->date_modification = $this->db->jdate($obj->date_modification);
+
$this->fk_departement = $obj->fk_departement; // deprecated
$this->state_id = $obj->fk_departement;
$this->departement_code = $obj->state_code; // deprecated
@@ -836,6 +857,7 @@ class Contact extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load number of elements the contact is used as a link for
* ref_facturation
@@ -847,6 +869,7 @@ class Contact extends CommonObject
*/
function load_ref_elements()
{
+ // phpcs:enable
// Compte les elements pour lesquels il est contact
$sql ="SELECT tc.element, count(ec.rowid) as nb";
$sql.=" FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
@@ -1177,6 +1200,7 @@ class Contact extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -1186,6 +1210,7 @@ class Contact extends CommonObject
*/
function LibStatut($statut,$mode)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
@@ -1222,6 +1247,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return translated label of Public or Private
*
@@ -1230,6 +1256,7 @@ class Contact extends CommonObject
*/
function LibPubPriv($statut)
{
+ // phpcs:enable
global $langs;
if ($statut=='1') return $langs->trans('ContactPrivate');
else return $langs->trans('ContactPublic');
@@ -1334,6 +1361,7 @@ class Contact extends CommonObject
* Existing categories are left untouch.
*
* @param int[]|int $categories Category or categories IDs
+ * @return void
*/
public function setCategories($categories)
{
diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php
index 1a60ddaaccb..07795da30d0 100644
--- a/htdocs/contact/document.php
+++ b/htdocs/contact/document.php
@@ -97,7 +97,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $title, -1, 'contact');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index d837a6c6421..b60fdd8886b 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -32,6 +32,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
@@ -76,6 +77,7 @@ $search_type=GETPOST('search_type','alpha');
$search_zip=GETPOST('search_zip','alpha');
$search_town=GETPOST('search_town','alpha');
$search_import_key=GETPOST("search_import_key","alpha");
+$search_country=GETPOST("search_country",'intcomma');
if ($search_status=='') $search_status=1; // always display activ customer first
@@ -148,10 +150,11 @@ $arrayfields=array(
'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1),
'p.town'=>array('label'=>"Town", 'checked'=>0),
'p.zip'=>array('label'=>"Zip", 'checked'=>0),
+ 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
'p.phone'=>array('label'=>"Phone", 'checked'=>1),
'p.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0),
'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1),
- 'p.fax'=>array('label'=>"Fax", 'checked'=>1),
+ 'p.fax'=>array('label'=>"Fax", 'checked'=>0),
'p.email'=>array('label'=>"EMail", 'checked'=>1),
'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))),
'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)),
@@ -203,6 +206,9 @@ if (empty($reshook))
$search_lastname="";
$search_firstname="";
$search_societe="";
+ $search_town="";
+ $search_zip="";
+ $search_country="";
$search_poste="";
$search_phone="";
$search_phone_perso="";
@@ -298,9 +304,10 @@ if ($search_id > 0) $sql.= natural_search("p.rowid",$search_id,1
if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname);
if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname);
if ($search_societe) $sql.= natural_search('s.nom', $search_societe);
+if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')';
if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste);
if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso);
-if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone);
+if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro);
if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile);
if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax);
if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype);
@@ -396,6 +403,7 @@ if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_
if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe);
if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip);
if ($search_town != '') $param.='&search_town='.urlencode($search_town);
+if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
if ($search_job != '') $param.='&search_job='.urlencode($search_job);
if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro);
if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso);
@@ -518,6 +526,12 @@ if (! empty($arrayfields['p.firstname']['checked']))
print '