Merge branch 'develop' of github.com:atm-maxime/dolibarr into new_choose_lines_from_origin

This commit is contained in:
Maxime Kohlhaas 2019-08-27 14:33:34 +02:00
commit 9c09876bd4
872 changed files with 26589 additions and 10586 deletions

View File

@ -115,12 +115,14 @@ Also, some code changes need a prior approbation:
Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR. Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR.
If the label of PR start with "WIP" (Work In Progress), it will not be analyzed (until you change the label of PR).
If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration.
If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet. If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet.
In most cases, it give you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the flag ask you. The majority of PR are waiting a developer action. In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the flag ask you. The majority of PR are waiting an action of the developer/author.
Around 95% of submitted PR are reviewed and tagged. Even if this is one of the most important ratio of answered PR in Open Source world, don't expect the core team to reach the 100%. With the increasing popularity of Dolibarr, this ratio will probably decrease in future. Statistics on Dolibarr project shows that around 95% of submitted PR are reviewed and tagged. This is one of the most important ratio of answered PR in Open Source world. Don't expect the core team to reach the 100%. With the increasing popularity of Dolibarr, this ratio will probably decrease in future.
### Resources ### Resources

5
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,5 @@
# These are supported funding model platforms
open_collective: dolibarr
custom: https://wiki.dolibarr.org/index.php/Subscribe
# github: [eldy]

View File

@ -1,8 +1,16 @@
---
name: Bug report
about: Create a report to help us fix something that is broken
title: ''
labels: Bug
assignees: ''
---
# Instructions # Instructions
*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.* *This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*
*Please:* *Please:*
- *only keep the "Bug" or "Feature Request" section* - *replace the bracket enclosed texts with meaningful information*
- *replace the bracket enclosed texts with meaningful informations*
- *remove any unused sub-section* - *remove any unused sub-section*
@ -25,17 +33,3 @@
## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…) ## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)
[*Files*] [*Files*]
# Feature Request
[*Short description*]
## Use case
[*Verbose description*]
## Suggested implementation
[*Verbose description*]
## Suggested steps
[*List of tasks to achieve goal*]

View File

@ -0,0 +1,27 @@
---
name: Feature request
about: Suggest a new idea for this project
title: ''
labels: Feature request
assignees: ''
---
# Instructions
*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*
*Please:*
- *replace the bracket enclosed texts with meaningful information*
- *remove any unused sub-section*
# Feature Request
[*Short description*]
## Use case
[*Verbose description*]
## Suggested implementation
[*Verbose description*]
## Suggested steps
[*List of tasks to achieve goal*]

View File

@ -1,6 +1,12 @@
# .scrutinizer.yml # .scrutinizer.yml
#build: #build:
# - php-scrutinizer-run # - php-scrutinizer-run
build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
imports: imports:
- javascript - javascript

10
.stickler.yml Normal file
View File

@ -0,0 +1,10 @@
---
linters:
phpcs:
standard: 'dev/setup/codesniffer/ruleset.xml'
extensions: 'php'
tab_width: 4
fixer: true
fixers:
enable: true

View File

@ -288,17 +288,17 @@ script:
# Ensure we catch errors # Ensure we catch errors
set -e set -e
#parallel-lint --exclude htdocs/includes --blame . #parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame . parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame .
set +e set +e
echo echo
- | - |
echo "Checking coding style" echo "Checking coding style (excluding Pull Requests builds)"
# Ensure we catch errors # Ensure we catch errors
set -e set -e
# Exclusions are defined in the ruleset.xml file # Exclusions are defined in the ruleset.xml file
#phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . #phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 .
phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi
set +e set +e
echo echo

View File

@ -32,7 +32,7 @@ PSR/simple-cache ? Library for cache (used by PHPSp
Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
Sabre 3.2.2 BSD Yes DAV support Sabre 3.2.2 BSD Yes DAV support
Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP
Stripe 6.35 MIT licence Yes Library for Stripe module Stripe 6.41 MIT licence Yes Library for Stripe module
TCPDF 6.2.25 LGPL-3+ Yes PDF generation TCPDF 6.2.25 LGPL-3+ Yes PDF generation
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement

219
ChangeLog
View File

@ -15,8 +15,227 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Properties ->libelle_incoterms were renamed into ->label_incoterms * Properties ->libelle_incoterms were renamed into ->label_incoterms
* Removed the method liste_array() of project class. It was not used by core code. * Removed the method liste_array() of project class. It was not used by core code.
* The function show_theme() hase been renamed into showSkins()
* Rename 'module_part' parameter into 'modulepart' into document APIs, for consistency.
***** ChangeLog for 10.0.1 compared to 10.0.0 *****
FIX: #10930
FIX: #10984
FIX: reposition on "Build backup" button
FIX: #11400
FIX: #11412
FIX: #11460
FIX: #11463
FIX: #11466
FIX: #11492
FIX: #11498
FIX: #11505
FIX: #11506
FIX: #11507
FIX: #11509
FIX: #11537
FIX: #11543
FIX: #11553
FIX: #11576
FIX: #11584
FIX: #11590
FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface
FIX: Add message from public interface
FIX: add missing hook calls
FIX: Add warning when setup is strange
FIX: ajax call for line positioning when CSRFCHECK_WITH_TOKEN is on
FIX: API return 404 sometimes even if API exists
FIX: Attachment was lost when we validate an expense report
FIX: avoid conflict with "$classname" in card.php
FIX: Bad sql request
FIX: better compatibility with multicompany transverse mode
FIX: Better PHP compatibility
FIX: Block to link with tickets
FIX: Can't submit a ticket from public interface
FIX: categories import: prevent mismatch between category type and object type
FIX: Closing ticket from public interface
FIX: Column 'paid' missing in expense report
FIX: compatibility mysql 8. rank is reserved
FIX: Computed field were not calculated into lists.
FIX: Content of email for subscription
FIX: correct error in files with multiple spaces
FIX: CVE-2019-11199
FIX: delete of links between objects
FIX: div not balanced
FIX: do not return formatted prices in json string
FIX: duplicate on the check (TODO field $onetrtd not used ?)
FIX: element name in update_price
FIX: empty product_use_units in product configuration
FIX: expedition card: infinite loop for printObjectLine hook if return > 0
FIX: extrafield loading bug due to assumption that an object is a third party while it may be a contact if MAIN_USE_COMPANY_NAME_OF_CONTACT is set.
FIX: Fatal error on dol_htmloutput_mesg with corrupted array
FIX: Fatal situation if payment removed on expense report. Action
FIX: FEC Format - Missing date_creation in general ledger when you add a new transaction
FIX: FEC Format - Save translation of the journal label in database & nowrap on amount
FIX: floating point precision errors in the triggers of the workflow module
FIX: for #11232
FIX: format of field with type timestamp
FIX: fournrprice log for insert
FIX: help text
FIX: import filter error
FIX: __INFOS__ tag not exists
FIX: issue #9300: install error with PostgreSQL when using custom table prefix
FIX: Language key
FIX: Limit of uploaded files (max_post_size was not used)
FIX: list of balance of leaves
FIX: minor spelling issues
FIX: missing "dropdown-icon" replacement
FIX: Missing field "Conciliated" into bank transaction export
FIX: missing filter by current contact
FIX: missing token
FIX: Missing where on entity
FIX: move sql request in INNER JOIN
FIX: name was able to be in field but went back to new line
FIX: Nowrap on amount
FIX: Online payment
FIX: on shipment delete confirm dialog, a new checkbox allows the user to choose if they want their stock re-incremented after the deletion.
FIX: option EXPORT_LABEL_FOR_SELECT to restore compatibility in export
FIX: Option THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION
FIX: outdated phpdoc
FIX: Permission for BOM menu
FIX: permission to delete a draft purchase order
FIX: phpcs
FIX: Position was lost when we edit the line of template invoice
FIX: product_use_units was set to 0 each time a conf in block other was set
FIX: propal createFrom hook: undefined parameter attached
FIX: Responsive of public interface of ticket
FIX: search by phone pro
FIX: Setup of TakePos was not possible after a clean install
FIX: Show list of events on tickets
FIX: socpeople assigned list in action com list
FIX: SQL problem on donation & nowrap on amount
FIX: stock increase on shipment deletion if STOCK_CALCULATE_ON_SHIPMENT_NEW: is set
FIX: stripe webhook ID constant set
FIX: summary of time spent in preview tab of projects
FIX: the feature to bill time spent was not enabled.
FIX: The new feature to attach document on lines was not correclty
FIX: The proposed new supplier code does not work
FIX: this function can not be private
FIX: tk9877 - PDF rouget requires product.lib.php (otherwise measuring_units_string() is not defined)
FIX: Update the file index table when we validate/rename a ref.
FIX: use rounding to compare the amounts
FIX: We must save code instead of value in database for template invoice modelpdf
FIX: we need to be able to add freeline with qty between 0 & 1 in supplierorder line
FIX: We should remove property comments only for project and task api.
FIX: When saving an action it didn't save the label based on the type of event if the label is empty and the type is customized
FIX: when STOCK_CALCULATE_ON_SHIPMENT_NEW: is set, deleting a "closed" shipment now increases stock as expected
FIX: wrong path sociales/index.php doesnt exist anymore
***** ChangeLog for 10.0.1 compared to 10.0.0 *****
FIX: #10930
FIX: #10984
FIX: reposition on "Build backup" button
FIX: #11400
FIX: #11412
FIX: #11460
FIX: #11463
FIX: #11466
FIX: #11492
FIX: #11498
FIX: #11505
FIX: #11506
FIX: #11507
FIX: #11509
FIX: #11537
FIX: #11543
FIX: #11553
FIX: #11576
FIX: #11584
FIX: #11590
FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface
FIX: Add message from public interface
FIX: add missing hook calls
FIX: Add warning when setup is strange
FIX: ajax call for line positioning when CSRFCHECK_WITH_TOKEN is on
FIX: API return 404 sometimes even if API exists
FIX: Attachment was lost when we validate an expense report
FIX: avoid conflict with "$classname" in card.php
FIX: Bad sql request
FIX: better compatibility with multicompany transverse mode
FIX: Better PHP compatibility
FIX: Block to link with tickets
FIX: Can't submit a ticket from public interface
FIX: categories import: prevent mismatch between category type and object type
FIX: Closing ticket from public interface
FIX: Column 'paid' missing in expense report
FIX: compatibility mysql 8. rank is reserved
FIX: Computed field were not calculated into lists.
FIX: Content of email for subscription
FIX: correct error in files with multiple spaces
FIX: CVE-2019-11199
FIX: delete of links between objects
FIX: div not balanced
FIX: do not return formatted prices in json string
FIX: duplicate on the check (TODO field $onetrtd not used ?)
FIX: element name in update_price
FIX: empty product_use_units in product configuration
FIX: expedition card: infinite loop for printObjectLine hook if return > 0
FIX: extrafield loading bug due to assumption that an object is a third party while it may be a contact if MAIN_USE_COMPANY_NAME_OF_CONTACT is set.
FIX: Fatal error on dol_htmloutput_mesg with corrupted array
FIX: Fatal situation if payment removed on expense report. Action
FIX: FEC Format - Missing date_creation in general ledger when you add a new transaction
FIX: FEC Format - Save translation of the journal label in database & nowrap on amount
FIX: floating point precision errors in the triggers of the workflow module
FIX: for #11232
FIX: format of field with type timestamp
FIX: fournrprice log for insert
FIX: help text
FIX: import filter error
FIX: __INFOS__ tag not exists
FIX: issue #9300: install error with PostgreSQL when using custom table prefix
FIX: Language key
FIX: Limit of uploaded files (max_post_size was not used)
FIX: list of balance of leaves
FIX: minor spelling issues
FIX: missing "dropdown-icon" replacement
FIX: Missing field "Conciliated" into bank transaction export
FIX: missing filter by current contact
FIX: missing token
FIX: Missing where on entity
FIX: move sql request in INNER JOIN
FIX: name was able to be in field but went back to new line
FIX: Nowrap on amount
FIX: Online payment
FIX: on shipment delete confirm dialog, a new checkbox allows the user to choose if they want their stock re-incremented after the deletion.
FIX: option EXPORT_LABEL_FOR_SELECT to restore compatibility in export
FIX: Option THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION
FIX: outdated phpdoc
FIX: Permission for BOM menu
FIX: permission to delete a draft purchase order
FIX: phpcs
FIX: Position was lost when we edit the line of template invoice
FIX: product_use_units was set to 0 each time a conf in block other was set
FIX: propal createFrom hook: undefined parameter attached
FIX: Responsive of public interface of ticket
FIX: search by phone pro
FIX: Setup of TakePos was not possible after a clean install
FIX: Show list of events on tickets
FIX: socpeople assigned list in action com list
FIX: SQL problem on donation & nowrap on amount
FIX: stock increase on shipment deletion if STOCK_CALCULATE_ON_SHIPMENT_NEW: is set
FIX: stripe webhook ID constant set
FIX: summary of time spent in preview tab of projects
FIX: the feature to bill time spent was not enabled.
FIX: The new feature to attach document on lines was not correclty
FIX: The proposed new supplier code does not work
FIX: this function can not be private
FIX: tk9877 - PDF rouget requires product.lib.php (otherwise measuring_units_string() is not defined)
FIX: Update the file index table when we validate/rename a ref.
FIX: use rounding to compare the amounts
FIX: We must save code instead of value in database for template invoice modelpdf
FIX: we need to be able to add freeline with qty between 0 & 1 in supplierorder line
FIX: We should remove property comments only for project and task api.
FIX: When saving an action it didn't save the label based on the type of event if the label is empty and the type is customized
FIX: when STOCK_CALCULATE_ON_SHIPMENT_NEW: is set, deleting a "closed" shipment now increases stock as expected
FIX: wrong path sociales/index.php doesnt exist anymore
***** ChangeLog for 10.0.0 compared to 9.0.0 ***** ***** ChangeLog for 10.0.0 compared to 9.0.0 *****
For Users: For Users:
NEW: Module "Ticket" is available as a stable module. NEW: Module "Ticket" is available as a stable module.

View File

@ -1,7 +1,6 @@
# DOLIBARR ERP & CRM # DOLIBARR ERP & CRM
![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg) ![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg)
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
|7|8|9|10|develop| |7|8|9|10|develop|
|----------|----------|----------|----------|----------| |----------|----------|----------|----------|----------|
@ -138,7 +137,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Multi-company by adding of an external module. - Multi-company by adding of an external module.
- Very user friendly and easy to use. - Very user friendly and easy to use.
- Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one)
- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) - Works with PHP 5.5+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite))
- Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites.
- APIs. - APIs.
- An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) - An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture)

13
SECURITY.md Normal file
View File

@ -0,0 +1,13 @@
# Security Policy
## Supported Versions
| Version | Supported |
| -------- | ------------------ |
| <= 8.0.* | :x: |
| >= 9.0.* | :white_check_mark: |
## Reporting a Vulnerability
To report a vulnerability, please send an email to security@dolibarr.org
In most cases, after fixing the security, we make an answer by email to say the issue has been fixed.

View File

@ -458,16 +458,6 @@ variables_order = "GPCS"
; with user data. This makes most sense when coupled with track_vars - in which ; with user data. This makes most sense when coupled with track_vars - in which
; case you can access all of the GPC variables through the $HTTP_*_VARS[], ; case you can access all of the GPC variables through the $HTTP_*_VARS[],
; variables. ; variables.
;
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
register_globals = Off
; Whether or not to register the old-style input arrays, HTTP_GET_VARS
; and friends. If you're not using them, it's recommended to turn them off,
; for performance reasons.
register_long_arrays = Off
; This directive tells PHP whether to declare the argv&argc variables (that ; This directive tells PHP whether to declare the argv&argc variables (that
; would contain the GET information). If you don't use these variables, you ; would contain the GET information). If you don't use these variables, you
@ -477,8 +467,7 @@ register_argc_argv = Off
; When enabled, the SERVER and ENV variables are created when they're first ; When enabled, the SERVER and ENV variables are created when they're first
; used (Just In Time) instead of when the script starts. If these variables ; used (Just In Time) instead of when the script starts. If these variables
; are not used within a script, having this directive on will result in a ; are not used within a script, having this directive on will result in a
; performance gain. The PHP directives register_globals, register_long_arrays, ; performance gain.
; and register_argc_argv must be disabled for this directive to have any affect.
auto_globals_jit = On auto_globals_jit = On
; Maximum size of POST data that PHP will accept. ; Maximum size of POST data that PHP will accept.
@ -1101,14 +1090,6 @@ session.gc_maxlifetime = 1800
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): ; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm ; cd /path/to/sessions; find -cmin +24 | xargs rm
; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit register_globals
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning separately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.
session.bug_compat_42 = 0
session.bug_compat_warn = 1
; Check HTTP Referer to invalidate externally stored URLs containing ids. ; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be ; HTTP_REFERER has to contain this substring for the session to be

View File

@ -29,16 +29,6 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
ErrorDocument 401 /public/error-401.php ErrorDocument 401 /public/error-401.php
ErrorDocument 404 /public/error-404.php ErrorDocument 404 /public/error-404.php
<IfModule mod_php4.c>
php_flag magic_quotes_gpc Off
php_flag register_globals Off
</IfModule>
<IfModule mod_php5.c>
php_flag magic_quotes_gpc Off
php_flag register_globals Off
</IfModule>
# OPTIMIZE: To use gzip compressed files (for Dolibarr already compressed files). # OPTIMIZE: To use gzip compressed files (for Dolibarr already compressed files).
# Note that constant MAIN_OPTIMIZE_SPEED must have a value with bit 0 set. # Note that constant MAIN_OPTIMIZE_SPEED must have a value with bit 0 set.

View File

@ -0,0 +1,4 @@
Test to migrate Dolibarr to namespace "Dolibarr".
Script bbb.php is a script of an external module with current code writing.
It must works after migration.

View File

@ -0,0 +1,23 @@
<?php
namespace Dolibarr;
global $globalaaa;
$globalaaa = 'globalaaa';
function faaa()
{
return 'faaa';
}
class Aaa
{
const AAA='aaa';
public function do()
{
echo 'doaaa'."\n";
}
}

View File

@ -0,0 +1,25 @@
<?php
global $globalbbb;
$globalbbb = 'globalbbb';
function fbbb()
{
return 'fbbb';
}
class Bbb
{
const BBB='bbb';
public function do()
{
global $globalaaa, $globalbbb;
echo 'dobbb'."\n";
$globalaaa.='+bbb';
$globalbbb.='+bbb';
}
}

31
dev/namespacemig/bbb.php Executable file
View File

@ -0,0 +1,31 @@
<?php
//use \Aaa as Aaa;
use Dolibarr\Aaa as Aaa;
use function Dolibarr\faaa as faaa; // Need php 5.6+
//use const Dolibarr\AAA;
//use Bbb as Bbb;
require './main.inc.php';
require './aaa.class.php';
require './bbb.class.php';
$bbb = new Bbb();
$bbb->do();
$aaa = new Aaa();
$aaa->do();
echo $aaa::AAA."\n";
echo $bbb::BBB."\n";
echo Aaa::AAA."\n";
echo Bbb::BBB."\n";
echo faaa()."\n";
echo fbbb()."\n";
echo "globalaaa=$globalaaa\n";
echo "globalbbb=$globalbbb\n";

View File

@ -0,0 +1,7 @@
<?php
/*spl_autoload_register(function ($class_name) {
var_dump('class='.$class_name);
require $class_name;
});
*/

View File

@ -658,20 +658,6 @@ html_errors = Off
; Example: ; Example:
;arg_separator.input = ";&" ;arg_separator.input = ";&"
; This directive determines which super global arrays are registered when PHP
; starts up. If the register_globals directive is enabled, it also determines
; what order variables are populated into the global space. G,P,C,E & S are
; abbreviations for the following respective super globals: GET, POST, COOKIE,
; ENV and SERVER. There is a performance penalty paid for the registration of
; these arrays and because ENV is not as commonly used as the others, ENV is
; is not recommended on productions servers. You can still get access to
; the environment variables through getenv() should you need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order
variables_order = "GPCS"
; This directive determines which super global data (G,P,C,E & S) should ; This directive determines which super global data (G,P,C,E & S) should
; be registered into the super global array REQUEST. If so, it also determines ; be registered into the super global array REQUEST. If so, it also determines
; the order in which that data is registered. The values for this directive are ; the order in which that data is registered. The values for this directive are
@ -685,15 +671,6 @@ variables_order = "GPCS"
; http://php.net/request-order ; http://php.net/request-order
request_order = "GP" request_order = "GP"
; Whether or not to register the EGPCS variables as global variables. You may
; want to turn this off if you don't want to clutter your scripts' global scope
; with user data.
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
; http://php.net/register-globals
register_globals = Off
; Determines whether the deprecated long $HTTP_*_VARS type predefined variables ; Determines whether the deprecated long $HTTP_*_VARS type predefined variables
; are registered by PHP or not. As they are deprecated, we obviously don't ; are registered by PHP or not. As they are deprecated, we obviously don't
; recommend you use them. They are on by default for compatibility reasons but ; recommend you use them. They are on by default for compatibility reasons but
@ -722,8 +699,7 @@ register_argc_argv = Off
; When enabled, the SERVER and ENV variables are created when they're first ; When enabled, the SERVER and ENV variables are created when they're first
; used (Just In Time) instead of when the script starts. If these variables ; used (Just In Time) instead of when the script starts. If these variables
; are not used within a script, having this directive on will result in a ; are not used within a script, having this directive on will result in a
; performance gain. The PHP directives register_globals, register_long_arrays, ; performance gain.
; and register_argc_argv must be disabled for this directive to have any affect.
; http://php.net/auto-globals-jit ; http://php.net/auto-globals-jit
auto_globals_jit = On auto_globals_jit = On
@ -1516,22 +1492,6 @@ session.gc_maxlifetime = 1440
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): ; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; find /path/to/sessions -cmin +24 | xargs rm ; find /path/to/sessions -cmin +24 | xargs rm
; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, even when register_globals
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning separately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled. This feature
; introduces some serious security problems if not handled correctly. It's
; recommended that you do not use this feature on production servers. But you
; should enable this on development servers and enable the warning as well. If you
; do not enable the feature on development servers, you won't be warned when it's
; used and debugging errors caused by this can be difficult to track down.
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/session.bug-compat-42
session.bug_compat_42 = Off
; This setting controls whether or not you are warned by PHP when initializing a ; This setting controls whether or not you are warned by PHP when initializing a
; session value into the global space. session.bug_compat_42 must be enabled before ; session value into the global space. session.bug_compat_42 must be enabled before
; these warnings can be issued by PHP. See the directive above for more information. ; these warnings can be issued by PHP. See the directive above for more information.

View File

@ -5,7 +5,9 @@
<exclude-pattern type="relative">build/html</exclude-pattern> <exclude-pattern type="relative">build/html</exclude-pattern>
<exclude-pattern type="relative">build/aps</exclude-pattern> <exclude-pattern type="relative">build/aps</exclude-pattern>
<exclude-pattern type="relative">dev/namespacemig</exclude-pattern>
<exclude-pattern type="relative">documents</exclude-pattern> <exclude-pattern type="relative">documents</exclude-pattern>
<exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern>
<exclude-pattern type="relative">htdocs/custom</exclude-pattern> <exclude-pattern type="relative">htdocs/custom</exclude-pattern>
<exclude-pattern type="relative">htdocs/includes</exclude-pattern> <exclude-pattern type="relative">htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">htdocs/install/doctemplates/websites</exclude-pattern> <exclude-pattern type="relative">htdocs/install/doctemplates/websites</exclude-pattern>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -156,17 +156,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$ok=1; $ok=1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value)
{ {
if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancyCategory','Pcg_version'))) continue; // For some pages, country is not mandatory if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
if ($value == 'country' && in_array($tablib[$id], array('DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory if ((! isset($_POST[$value]) || $_POST[$value]==''))
if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
if ($value == 'color' && empty($_POST['color'])) continue;
if ($value == 'formula' && empty($_POST['formula'])) continue;
if ((! isset($_POST[$value]) || $_POST[$value]=='')
&& (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy')) // Fields that are not mandatory
&& (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
)
)
{ {
$ok=0; $ok=0;
$fieldnamekey=$listfield[$f]; $fieldnamekey=$listfield[$f];
@ -174,19 +165,6 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version'; if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
if ($fieldnamekey == 'nbjour') $fieldnamekey='NbOfDays';
if ($fieldnamekey == 'decalage') $fieldnamekey='Offset';
if ($fieldnamekey == 'module') $fieldnamekey='Module';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'taux') $fieldnamekey = 'Rate';
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';
if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
@ -196,9 +174,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$ok=0; $ok=0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
} }
if (isset($_POST["code"])) if (isset($_POST["pcg_version"]))
{ {
if ($_POST["code"]=='0') if ($_POST["pcg_version"]=='0')
{ {
$ok=0; $ok=0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
@ -211,28 +189,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
} }
if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2))
{ {
if (in_array($tablib[$id], array('DictionaryCompanyType','DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries $ok=0;
{ setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
$_POST["country"]='';
}
else
{
$ok=0;
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
}
} }
if (! is_numeric($_POST["code"]))
{
$ok=0;
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
}
// Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) if ($ok && GETPOST('actionadd', 'alpha'))

View File

@ -73,19 +73,11 @@ $y = $year_current;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width=150>' . $langs->trans("Label") . '</td>'; print '<td width=150>' . $langs->trans("Label") . '</td>';
print '<td class="center">' . $langs->trans("JanuaryMin") . '</td>'; for($i = 1; $i <= 12; $i++)
print '<td class="center">' . $langs->trans("FebruaryMin") . '</td>'; {
print '<td class="center">' . $langs->trans("MarchMin") . '</td>'; print '<td class="right">' . $langs->trans("MonthShort".sprintf("%02s", $i)) . '</td>';
print '<td class="center">' . $langs->trans("AprilMin") . '</td>'; }
print '<td class="center">' . $langs->trans("MayMin") . '</td>'; print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
print '<td class="center">' . $langs->trans("JuneMin") . '</td>';
print '<td class="center">' . $langs->trans("JulyMin") . '</td>';
print '<td class="center">' . $langs->trans("AugustMin") . '</td>';
print '<td class="center">' . $langs->trans("SeptemberMin") . '</td>';
print '<td class="center">' . $langs->trans("OctoberMin") . '</td>';
print '<td class="center">' . $langs->trans("NovemberMin") . '</td>';
print '<td class="center">' . $langs->trans("DecemberMin") . '</td>';
print '<td class="center"><strong>Total</strong></td>';
print '</tr>'; print '</tr>';
$sql = "SELECT bk.numero_compte AS 'compte',"; $sql = "SELECT bk.numero_compte AS 'compte',";

View File

@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php
$langs->loadLangs(array("accountancy", "bills", "compta")); $langs->loadLangs(array("accountancy", "bills", "compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int'); // id of record $id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' $mode = GETPOST('mode', 'aZ09'); // '' or 'tmp'
@ -346,6 +347,8 @@ if ($action == 'create')
} }
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n"; print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n"; print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
print '<input type="hidden" name="mode" value="_tmp">' . "\n"; print '<input type="hidden" name="mode" value="_tmp">' . "\n";
@ -441,7 +444,8 @@ if ($action == 'create')
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdate') { if ($action == 'editdate') {
print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate">'; print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
@ -464,7 +468,8 @@ if ($action == 'create')
print '</td><td>'; print '</td><td>';
if ($action == 'editjournal') { if ($action == 'editjournal') {
print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setjournal">'; print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1);
@ -487,7 +492,8 @@ if ($action == 'create')
print '</td><td>'; print '</td><td>';
if ($action == 'editdocref') { if ($action == 'editdocref') {
print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdocref">'; print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">'; print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
@ -583,6 +589,8 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n"; print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n"; print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n";
print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n"; print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n";
@ -641,8 +649,8 @@ if ($action == 'create')
print '<td>' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '</td>'; print '<td>' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_operation. '</td>'; print '<td>' . $line->label_operation. '</td>';
print '<td class="right">' . price($line->debit) . '</td>'; print '<td class="nowrap right">' . price($line->debit) . '</td>';
print '<td class="right">' . price($line->credit) . '</td>'; print '<td class="nowrap right">' . price($line->credit) . '</td>';
print '<td class="center">'; print '<td class="center">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
@ -675,7 +683,7 @@ if ($action == 'create')
print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, ''); print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{ {

View File

@ -789,7 +789,7 @@ if ($num > 0)
// Amount debit // Amount debit
if (! empty($arrayfields['t.debit']['checked'])) if (! empty($arrayfields['t.debit']['checked']))
{ {
print '<td class="right">' . ($line->debit ? price($line->debit) : ''). '</td>'; print '<td class="nowrap right">' . ($line->debit ? price($line->debit) : ''). '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield']; if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield'];
$totalarray['totaldebit'] += $line->debit; $totalarray['totaldebit'] += $line->debit;
@ -798,7 +798,7 @@ if ($num > 0)
// Amount credit // Amount credit
if (! empty($arrayfields['t.credit']['checked'])) if (! empty($arrayfields['t.credit']['checked']))
{ {
print '<td class="right">' . ($line->credit ? price($line->credit) : '') . '</td>'; print '<td class="nowrap right">' . ($line->credit ? price($line->credit) : '') . '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield']; if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield'];
$totalarray['totalcredit'] += $line->credit; $totalarray['totalcredit'] += $line->credit;
@ -879,8 +879,8 @@ if ($num > 0)
if ($num < $limit && empty($offset)) print '<td class="left">'.$langs->trans("Total").'</td>'; if ($num < $limit && empty($offset)) print '<td class="left">'.$langs->trans("Total").'</td>';
else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
} }
elseif ($totalarray['totaldebitfield'] == $i) print '<td class="right">'.price($totalarray['totaldebit']).'</td>'; elseif ($totalarray['totaldebitfield'] == $i) print '<td class="nowrap right">'.price($totalarray['totaldebit']).'</td>';
elseif ($totalarray['totalcreditfield'] == $i) print '<td class="right">'.price($totalarray['totalcredit']).'</td>'; elseif ($totalarray['totalcreditfield'] == $i) print '<td class="nowrap right">'.price($totalarray['totalcredit']).'</td>';
else print '<td></td>'; else print '<td></td>';
} }
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);

View File

@ -5,7 +5,7 @@
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr> * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
* Copyright (C) 2016-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2016-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com> * Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
@ -48,8 +48,10 @@ class AccountancyExport
public static $EXPORT_TYPE_BOB50 = 35; public static $EXPORT_TYPE_BOB50 = 35;
public static $EXPORT_TYPE_CIEL = 40; public static $EXPORT_TYPE_CIEL = 40;
public static $EXPORT_TYPE_SAGE50_SWISS = 45; public static $EXPORT_TYPE_SAGE50_SWISS = 45;
public static $EXPORT_TYPE_CHARLEMAGNE = 50;
public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_QUADRATUS = 60;
public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_OPENCONCERTO = 100;
public static $EXPORT_TYPE_LDCOMPTA = 110;
public static $EXPORT_TYPE_FEC = 1000; public static $EXPORT_TYPE_FEC = 1000;
@ -105,7 +107,9 @@ class AccountancyExport
self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'),
self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'),
self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
); );
ksort($listofexporttypes, SORT_NUMERIC); ksort($listofexporttypes, SORT_NUMERIC);
@ -133,6 +137,7 @@ class AccountancyExport
self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_AGIRIS => 'agiris',
self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
self::$EXPORT_TYPE_FEC => 'fec', self::$EXPORT_TYPE_FEC => 'fec',
); );
@ -191,10 +196,18 @@ class AccountancyExport
'label' => $langs->trans('Modelcsv_Sage50_Swiss'), 'label' => $langs->trans('Modelcsv_Sage50_Swiss'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv', 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
), ),
self::$EXPORT_TYPE_LDCOMPTA => array(
'label' => $langs->trans('Modelcsv_LDCompta'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
),
self::$EXPORT_TYPE_FEC => array( self::$EXPORT_TYPE_FEC => array(
'label' => $langs->trans('Modelcsv_FEC'), 'label' => $langs->trans('Modelcsv_FEC'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt', 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
), ),
self::$EXPORT_TYPE_CHARLEMAGNE => array(
'label' => $langs->trans('Modelcsv_charlemagne'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
),
), ),
'cr'=> array ( 'cr'=> array (
'1' => $langs->trans("Unix"), '1' => $langs->trans("Unix"),
@ -257,12 +270,18 @@ class AccountancyExport
case self::$EXPORT_TYPE_OPENCONCERTO : case self::$EXPORT_TYPE_OPENCONCERTO :
$this->exportOpenConcerto($TData); $this->exportOpenConcerto($TData);
break; break;
case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData);
break;
case self::$EXPORT_TYPE_SAGE50_SWISS : case self::$EXPORT_TYPE_SAGE50_SWISS :
$this->exportSAGE50SWISS($TData); $this->exportSAGE50SWISS($TData);
break; break;
case self::$EXPORT_TYPE_LDCOMPTA :
$this->exportLDCompta($TData);
break;
case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData);
break;
case self::$EXPORT_TYPE_CHARLEMAGNE :
$this->exportCharlemagne($TData);
break;
default: default:
$this->errors[] = $langs->trans('accountancy_error_modelnotfound'); $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
break; break;
@ -274,7 +293,6 @@ class AccountancyExport
* Export format : CEGID * Export format : CEGID
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportCegid($objectLines) public function exportCegid($objectLines)
@ -300,7 +318,6 @@ class AccountancyExport
* Export format : COGILOG * Export format : COGILOG
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportCogilog($objectLines) public function exportCogilog($objectLines)
@ -334,7 +351,6 @@ class AccountancyExport
* Export format : COALA * Export format : COALA
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportCoala($objectLines) public function exportCoala($objectLines)
@ -362,7 +378,6 @@ class AccountancyExport
* Export format : BOB50 * Export format : BOB50
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportBob50($objectLines) public function exportBob50($objectLines)
@ -401,7 +416,6 @@ class AccountancyExport
* Export format : CIEL * Export format : CIEL
* *
* @param array $TData data * @param array $TData data
*
* @return void * @return void
*/ */
public function exportCiel(&$TData) public function exportCiel(&$TData)
@ -442,7 +456,6 @@ class AccountancyExport
* Export format : Quadratus * Export format : Quadratus
* *
* @param array $TData data * @param array $TData data
*
* @return void * @return void
*/ */
public function exportQuadratus(&$TData) public function exportQuadratus(&$TData)
@ -526,7 +539,6 @@ class AccountancyExport
* Export format : EBP * Export format : EBP
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportEbp($objectLines) public function exportEbp($objectLines)
@ -563,7 +575,6 @@ class AccountancyExport
* Export format : Agiris Isacompta * Export format : Agiris Isacompta
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportAgiris($objectLines) public function exportAgiris($objectLines)
@ -604,7 +615,6 @@ class AccountancyExport
* Export format : OpenConcerto * Export format : OpenConcerto
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportOpenConcerto($objectLines) public function exportOpenConcerto($objectLines)
@ -634,16 +644,17 @@ class AccountancyExport
} }
/** /**
* Export format : Configurable * Export format : Configurable CSV
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportConfigurable($objectLines) public function exportConfigurable($objectLines)
{ {
global $conf; global $conf;
$separator = $this->separator;
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
$tab = array(); $tab = array();
// export configurable // export configurable
@ -651,15 +662,14 @@ class AccountancyExport
$tab[] = $line->piece_num; $tab[] = $line->piece_num;
$tab[] = $date; $tab[] = $date;
$tab[] = $line->doc_ref; $tab[] = $line->doc_ref;
$tab[] = $line->label_operation; $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
$tab[] = length_accountg($line->numero_compte); $tab[] = length_accountg($line->numero_compte);
$tab[] = length_accounta($line->subledger_account); $tab[] = length_accounta($line->subledger_account);
$tab[] = price($line->debit); $tab[] = price2num($line->debit);
$tab[] = price($line->credit); $tab[] = price2num($line->credit);
$tab[] = price($line->montant); $tab[] = price2num($line->montant);
$tab[] = $line->code_journal; $tab[] = $line->code_journal;
$separator = $this->separator;
print implode($separator, $tab) . $this->end_line; print implode($separator, $tab) . $this->end_line;
} }
} }
@ -668,7 +678,6 @@ class AccountancyExport
* Export format : FEC * Export format : FEC
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportFEC($objectLines) public function exportFEC($objectLines)
@ -909,6 +918,160 @@ class AccountancyExport
} }
} }
/**
* Export format : LD Compta version 9 & higher
* http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
*
* @param array $objectLines data
*
* @return void
*/
public function exportLDCompta($objectLines)
{
$separator = ';';
$end_line = "\n";
foreach ($objectLines as $line) {
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
// TYPE
$type_enregistrement = 'E'; // For write movement
print $type_enregistrement . $separator;
// JNAL
print substr($line->code_journal, 0, 2) . $separator;
// NECR
print $line->id . $separator;
// NPIE
print $line->piece_num . $separator;
// DATP
print $date_document . $separator;
// LIBE
print $line->label_operation . $separator;
// DATH
print $line->date_lim_reglement . $separator;
// CNPI
if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) {
$nature_piece = 'AF';
} else {
$nature_piece = 'FF';
}
} elseif ($line->doc_type == 'customer_invoice') {
if ($line->montant < 0) {
$nature_piece = 'AC';
} else {
$nature_piece = 'FC';
}
} else {
$nature_piece = '';
}
print $nature_piece . $separator;
// RACI
/*
if (! empty($line->subledger_account)) {
if ($line->doc_type == 'supplier_invoice') {
$racine_subledger_account = '40';
} elseif ($line->doc_type == 'customer_invoice') {
$racine_subledger_account = '41';
} else {
$nature_piece = '';
}
print $racine_subledger_account . $separator;
} else {
print $separator;
}
*/
// MONT
print price(abs($line->montant)) . $separator;
// CODC
print $line->sens . $separator;
// CPTG
print length_accountg($line->numero_compte) . $separator;
// DATE
print $date_creation . $separator;
// CLET
print $line->lettering_code . $separator;
// DATL
print $line->date_lettering . $separator;
// CPTA
if (! empty($line->subledger_account)) {
print length_accounta($line->subledger_account) . $separator;
}
// CNAT
if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) {
print 'F';
} elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) {
print 'C';
} else {
print '';
}
print $end_line;
}
}
/**
* Export format : Charlemagne
*
* @param array $objectLines data
* @return void
*/
public function exportCharlemagne($objectLines)
{
global $langs;
$langs->load('compta');
$separator = "\t";
$end_line = "\n";
/*
* Charlemagne export need header
*/
print $langs->transnoentitiesnoconv('Date') . $separator;
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator;
print $langs->transnoentitiesnoconv('Amount') . $separator;
print 'S' . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator;
print $end_line;
foreach($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%Y%m%d');
print $date . $separator; //Date
print self::trunc($line->code_journal, 6) . $separator; //Journal code
if(!empty($line->subledger_account)) $account = $line->subledger_account;
else $account = $line->numero_compte;
print self::trunc($account, 15) . $separator;//Account number
print self::trunc($line->label_compte, 60) . $separator;//Account label
print self::trunc($line->doc_ref, 20) . $separator;//Piece
print self::trunc($line->label_operation, 60) . $separator;//Operation label
print price(abs($line->montant)) . $separator;//Amount
print $line->sens . $separator;//Direction
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $end_line;
}
}
/** /**
* trunc * trunc
* *

View File

@ -469,14 +469,15 @@ class BookKeeping extends CommonObject
*/ */
public function createStd(User $user, $notrigger = false, $mode = '') public function createStd(User $user, $notrigger = false, $mode = '')
{ {
global $conf; global $conf, $langs;
$langs->loadLangs(array("accountancy", "bills", "compta"));
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->doc_type)) { if (isset($this->doc_type)) {
$this->doc_type = trim($this->doc_type); $this->doc_type = trim($this->doc_type);
} }
@ -540,7 +541,7 @@ class BookKeeping extends CommonObject
$now = dol_now(); $now = dol_now();
// Check parameters // Check parameters
// Put here code to add control on parameters values $this->journal_label = $langs->trans($this->journal_label);
// Insert request // Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' ('; $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' (';

View File

@ -1187,7 +1187,7 @@ else
} }
// Morphy // Morphy
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy)); print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy));
print "</td></tr>"; print "</td></tr>";

View File

@ -2315,6 +2315,7 @@ class Adherent extends CommonObject
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay=$conf->adherent->subscription->warning_delay/60/60/24; $response->warning_delay=$conf->adherent->subscription->warning_delay/60/60/24;
$response->label=$langs->trans("MembersWithSubscriptionToReceive"); $response->label=$langs->trans("MembersWithSubscriptionToReceive");
$response->labelShort=$langs->trans("MembersWithSubscriptionToReceiveShort");
$response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&amp;statut=1&amp;filter=outofdate'; $response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&amp;statut=1&amp;filter=outofdate';
$response->img=img_object('', "user"); $response->img=img_object('', "user");

View File

@ -53,21 +53,21 @@ class Subscription extends CommonObject
* @var integer * @var integer
*/ */
public $datec; public $datec;
/** /**
* Date modification record (tms) * Date modification record (tms)
* *
* @var integer * @var integer
*/ */
public $datem; public $datem;
/** /**
* Subscription start date (date subscription) * Subscription start date (date subscription)
* *
* @var integer * @var integer
*/ */
public $dateh; public $dateh;
/** /**
* Subscription end date * Subscription end date
* *
@ -128,10 +128,11 @@ class Subscription extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
if ($this->fk_type == null) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $member=new Adherent($this->db);
$member=new Adherent($this->db); $result=$member->fetch($this->fk_adherent);
$result=$member->fetch($this->fk_adherent);
if ($this->fk_type == null) { // If type not defined, we use the type of member
$type=$member->typeid; $type=$member->typeid;
} else { } else {
$type=$this->fk_type; $type=$this->fk_type;
@ -151,11 +152,13 @@ class Subscription extends CommonObject
if (! $error) if (! $error)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->fk_type = $type;
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call triggers $this->context = array('member'=>$member);
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
@ -257,7 +260,8 @@ class Subscription extends CommonObject
$result=$member->update_end_date($user); $result=$member->update_end_date($user);
if (! $error && ! $notrigger) { if (! $error && ! $notrigger) {
// Call triggers $this->context = array('member'=>$member);
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
// End call triggers // End call triggers

View File

@ -182,7 +182,7 @@ if ($result > 0)
if (empty($dn)) if (empty($dn))
{ {
$langs->load("errors"); $langs->load("errors");
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font></td></tr>'; print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>';
} }
else else
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -205,18 +205,18 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print $form->showrefnav($object, 'rowid', $linkback, 1); print $form->showrefnav($object, 'rowid', $linkback, 1);
print '</td></tr>'; print '</td></tr>';
// Type // Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
// Type
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">'; print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
print'</td></tr>'; print'</td></tr>';
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
// Date start subscription // Date start subscription
print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">'; print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">';
print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1);
@ -309,6 +309,12 @@ if ($rowid && $action != 'edit')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
// Type // Type
print '<tr>'; print '<tr>';
print '<td class="titlefield">'.$langs->trans("Type").'</td>'; print '<td class="titlefield">'.$langs->trans("Type").'</td>';
@ -322,17 +328,6 @@ if ($rowid && $action != 'edit')
} }
print '</td></tr>'; print '</td></tr>';
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
// Date record
/*print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->datec,'dayhour').'</td>';
print '</tr>';*/
// Date subscription // Date subscription
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>'; print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>';

View File

@ -342,7 +342,7 @@ if ($action == 'create')
// Morphy // Morphy
$morphys[""] = $langs->trans("MorPhy"); $morphys[""] = $langs->trans("MorPhy");
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td></tr>"; print "</td></tr>";
@ -775,7 +775,7 @@ if ($rowid > 0)
// Morphy // Morphy
$morphys[""] = $langs->trans("MorPhy"); $morphys[""] = $langs->trans("MorPhy");
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td></tr>"; print "</td></tr>";

View File

@ -37,12 +37,12 @@ $action = GETPOST('action', 'aZ09');
/* /*
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin)
{ {
$result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); $result1=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
$result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); $result2=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
if ($result1 >= 0 && $result2 >= 0) if ($result1 >= 0 && $result2 >= 0)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');

View File

@ -35,7 +35,10 @@ if (!$user->admin)
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$arrayofparameters=array( $arrayofparameters=array(
'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2), 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled) 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
@ -68,7 +71,6 @@ $head=dav_admin_prepare_head();
dol_fiche_head($head, 'webdav', '', -1, 'action'); dol_fiche_head($head, 'webdav', '', -1, 'action');
if ($action == 'edit') if ($action == 'edit')
{ {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -76,14 +78,17 @@ if ($action == 'edit')
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val) foreach($arrayofparameters as $key => $val)
{ {
if (isset($val['enabled']) && empty($val['enabled'])) continue; if (isset($val['enabled']) && empty($val['enabled'])) continue;
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
$label = $langs->trans($key);
if ($key == 'DAV_RESTICT_ON_IP') $label = $langs->trans("RESTRICT_ON_IP");
print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR')
{ {
@ -112,12 +117,13 @@ if ($action == 'edit')
else else
{ {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val) foreach($arrayofparameters as $key => $val)
{ {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR')
{ {
@ -177,6 +183,13 @@ if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
} }
print $message; print $message;
print '<br><br><br>';
require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
$version = Sabre\DAV\Version::VERSION;
print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -195,7 +195,6 @@ if ($action == 'edit')
{ {
foreach($delays as $delay) foreach($delays as $delay)
{ {
$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; print '<td width="20px">'.img_object('', $delay['img']).'</td>';
@ -235,7 +234,6 @@ else
{ {
foreach($delays as $delay) foreach($delays as $delay)
{ {
$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; print '<td width="20px">'.img_object('', $delay['img']).'</td>';
@ -264,7 +262,7 @@ else
print '<br>'; print '<br>';
// Show logo for weather // Show logo for weather
print $langs->trans("DescWeather").'<br>'; print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
if($action == 'edit') { if($action == 'edit') {
@ -300,16 +298,16 @@ if ($action == 'edit') {
print '<div>'; print '<div>';
print '<div class="inline-block" style="padding-right: 20px">'; print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options); print img_weather($text, 0, $options);
print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>'; print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options); print img_weather($text, 1, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options); print img_weather($text, 2, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options); print img_weather($text, 3, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
@ -320,16 +318,16 @@ if ($action == 'edit') {
print '<div>'; print '<div>';
print '<div class="inline-block" style="padding-right: 20px">'; print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options); print img_weather($text, 0, $options);
print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options); print img_weather($text, 1, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options); print img_weather($text, 2, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options); print img_weather($text, 3, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>'; print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
@ -371,19 +369,19 @@ if ($action == 'edit') {
print '<div>'; print '<div>';
print '<div class="inline-block" style="padding-right: 20px">'; print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options); print img_weather($text, 0, $options);
print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>'; print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options); print img_weather($text, 1, $options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>'; print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options); print img_weather($text, 2, $options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>'; print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options); print img_weather($text, 3, $options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>'; print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-storm.png', $options); print img_weather($text, 4, $options);
print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>'; print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
@ -391,19 +389,19 @@ if ($action == 'edit') {
print '<div>'; print '<div>';
print '<div class="inline-block" style="padding-right: 20px">'; print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options); print img_weather($text, 0, $options);
print '= '.$level0; print '= '.$level0;
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options); print img_weather($text, 1, $options);
print '&lt;= '.$level1; print '&lt;= '.$level1;
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options); print img_weather($text, 2, $options);
print '&lt;= '.$level2; print '&lt;= '.$level2;
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options); print img_weather($text, 3, $options);
print '&lt;= '.$level3; print '&lt;= '.$level3;
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-storm.png', $options); print img_weather($text, 4, $options);
print '&gt; '.$level3; print '&gt; '.$level3;
print '</div>'; print '</div>';
print '</div>'; print '</div>';

View File

@ -1058,7 +1058,7 @@ if ($id)
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
$class=''; $class='';
if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='width100'; } if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='maxwidth100'; }
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
if ($fieldlist[$field]=='taux') { if ($fieldlist[$field]=='taux') {
@ -1076,7 +1076,7 @@ if ($id)
if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
else $valuetoshow=$langs->trans("Type"); else $valuetoshow=$langs->trans("Type");
} }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='width100'; } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='maxwidth100'; }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
{ {
$valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
@ -1602,7 +1602,6 @@ if ($id)
$class='tddict'; $class='tddict';
if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200';
if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
if ($fieldlist[$field] == 'code') $class.=' width100';
if ($fieldlist[$field] == 'position') $class.=' right'; if ($fieldlist[$field] == 'position') $class.=' right';
if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap';
if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap';
@ -1780,7 +1779,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
global $form; global $form;
global $region_id; global $region_id;
global $elementList,$sourceList,$localtax_typeList; global $elementList,$sourceList,$localtax_typeList;
global $bc;
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
@ -1981,7 +1979,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
} }
$classtd=''; $class=''; $classtd=''; $class='';
if ($fieldlist[$field]=='code') $classtd='width100'; if ($fieldlist[$field]=='code') $class='maxwidth100';
if (in_array($fieldlist[$field], array('pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50'; if (in_array($fieldlist[$field], array('pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50';
if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent'; if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent';
print '<td class="'.$classtd.'">'; print '<td class="'.$classtd.'">';

View File

@ -0,0 +1,228 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/facture.php
* \ingroup facture
* \brief Page to setup invoice module
*/
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.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
if (! $user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type='invoice';
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
/*
* View
*/
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader(
"", $langs->trans("BillsSetup"),
'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
);
$form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
$head = invoice_admin_prepare_head();
dol_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
/*
* Numbering module
*/
print load_fiche_titre($langs->trans("InvoiceSituation"), '', '');
$var=0;
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
_updateBtn();
print '<table class="noborder" width="100%">';
_printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices'));
_printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote'));
_printOnOff('INVOICE_USE_SITUATION_RETAINED_WARRANTY', $langs->trans('Retainedwarranty'));
$metas = array(
'type' => 'number',
'step' => '0.01',
'min' => 0,
'max' => 100
);
_printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas);
// Conditions paiements
$inputCount = empty($inputCount)?1:($inputCount+1);
print '<tr class="impair">';
print '<td>'.$langs->trans('PaymentConditionsShortRetainedWarranty').'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print '<input type="hidden" name="param'.$inputCount.'" value="INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID">';
$form->select_conditions_paiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'value'.$inputCount, -1, 1);
print '</td></tr>';
print '</table>';
_updateBtn();
print '</form>';
dol_fiche_end();
// End of page
llxFooter();
$db->close();
/**
* Print an update button
*
* @return void
*/
function _updateBtn()
{
global $langs;
print '<div style="text-align: right;" >';
print '<input type="submit" class="butAction" value="'.$langs->trans("Save").'">';
print '</div>';
}
/**
* Print a On/Off button
*
* @param string $confkey the conf key
* @param bool $title Title of conf
* @param string $desc Description
*
* @return void
*/
function _printOnOff($confkey, $title = false, $desc = '')
{
global $var, $bc, $langs;
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.($title?$title:$langs->trans($confkey));
if (!empty($desc)) {
print '<br><small>'.$langs->trans($desc).'</small>';
}
print '</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print ajax_constantonoff($confkey);
print '</td></tr>';
}
/**
* Print a form part
*
* @param string $confkey the conf key
* @param bool $title Title of conf
* @param string $desc Description of
* @param array $metas html meta
* @param string $type type of input textarea or input
* @param bool $help help description
*
* @return void
*/
function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false)
{
global $var, $bc, $langs, $conf, $db, $inputCount;
$var=!$var;
$inputCount = empty($inputCount)?1:($inputCount+1);
$form=new Form($db);
$defaultMetas = array(
'name' => 'value'.$inputCount
);
if ($type!='textarea') {
$defaultMetas['type'] = 'text';
$defaultMetas['value'] = $conf->global->{$confkey};
}
$metas = array_merge($defaultMetas, $metas);
$metascompil = '';
foreach ($metas as $key => $values) {
$metascompil .= ' '.$key.'="'.$values.'" ';
}
print '<tr '.$bc[$var].'>';
print '<td>';
if (!empty($help)) {
print $form->textwithtooltip(($title?$title:$langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
} else {
print $title?$title:$langs->trans($confkey);
}
if (!empty($desc)) {
print '<br><small>'.$langs->trans($desc).'</small>';
}
print '</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print '<input type="hidden" name="param'.$inputCount.'" value="'.$confkey.'">';
print '<input type="hidden" name="action" value="setModuleOptions">';
if ($type=='textarea') {
print '<textarea '.$metascompil.' >'.dol_htmlentities($conf->global->{$confkey}).'</textarea>';
} else {
print '<input '.$metascompil.' />';
}
print '</td></tr>';
}

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.org> /* Copyright (C) 2009-2019 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -36,9 +36,11 @@ $langs->loadLangs(array("admin","errors"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
/* /*
* Actions * Actions
*/ */
if ($action == 'set') if ($action == 'set')
{ {
$error=0; $error=0;
@ -53,8 +55,11 @@ if ($action == 'set')
if (! $error) if (! $error)
{ {
$res = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++; if (! $res1 > 0) $error++;
$res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
if (! $res2 > 0) $error++;
if (! $error) if (! $error)
{ {
@ -67,6 +72,8 @@ if ($action == 'set')
} }
} }
if (! isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2';
/* /*
* View * View
@ -85,13 +92,6 @@ $geoip='';
if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE))
{ {
$geoip=new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); $geoip=new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
//if ($geoip->error) print dol_htmloutput_errors($geoip->errorlabel,'',1);
if ($geoip->gi == 'NOGI') $geointernal=true;
else $geointernal=false;
}
else
{
if (function_exists('geoip_country_code_by_name')) $geointernal=true;
} }
// Mode // Mode
@ -105,16 +105,30 @@ print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td
print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'</td>'; // Lib version
print '<tr class="oddeven"><td width="50%">'.$langs->trans("GeoIPLibVersion").'</td>';
print '<td colspan="2">';
$arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v1', '2' => 'Embedded GeoIP v2');
print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2'));
if ($conf->global->GEOIP_VERSION == 'php')
{
if ($geoip) $version=$geoip->getVersion();
if ($version)
{
print '<br>'.$langs->trans("Version").': '.$version;
}
}
print '</td></tr>';
// Path to database file
print '<tr class="oddeven"><td>'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
if ($geointernal) print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).'<br>'; if ($conf->global->GEOIP_VERSION == 'php')
print '<input size="50" type="text" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE.'">';
if ($geoip) $version=$geoip->getVersion();
if ($version)
{ {
print '<br>'.$langs->trans("Version").': '.$version; print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).' or /pathtodatafile/GeoLite2-Country.mmdb<br>';
} }
print '<input size="50" type="text" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE.'">';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -144,6 +158,13 @@ if ($geoip)
if ($result) print $result; if ($result) print $result;
else print $langs->trans("Error"); else print $langs->trans("Error");
$ip='2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France
print '<br>'.$ip.' -> ';
$result=dol_print_ip($ip, 1);
if ($result) print $result;
else print $langs->trans("Error");
/* We disable this test because dol_print_ip need an ip as input /* We disable this test because dol_print_ip need an ip as input
$ip='www.google.com'; $ip='www.google.com';
print '<br>'.$ip.' -> '; print '<br>'.$ip.' -> ';

View File

@ -259,7 +259,7 @@ if ($action == 'edit') // Edit
print '</table><br>'."\n"; print '</table><br>'."\n";
// Themes and themes options // Themes and themes options
show_theme(null, 1); showSkins(null, 1);
print '<br>'; print '<br>';
// Other // Other
@ -464,7 +464,7 @@ else // Show
// Themes // Themes
show_theme(null, 0); showSkins(null, 0);
print '<br>'; print '<br>';

View File

@ -130,13 +130,13 @@ if ($action=='install')
} }
else else
{ {
if (! preg_match('/\.zip$/i', $original_file)) if (! $error && ! preg_match('/\.zip$/i', $original_file))
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors'); setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors');
$error++; $error++;
} }
if (! preg_match('/module_.*\-[\d]+\.[\d]+.*$/i', $original_file)) if (! $error && ! preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file))
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors'); setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors');
@ -180,13 +180,13 @@ if ($action=='install')
{ {
// Now we move the dir of the module // Now we move the dir of the module
$modulename=preg_replace('/module_/', '', $original_file); $modulename=preg_replace('/module_/', '', $original_file);
$modulename=preg_replace('/\-[\d]+\.[\d]+.*$/', '', $modulename); $modulename=preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename);
// Search dir $modulename // Search dir $modulename
$modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example .../mymodule
//var_dump($modulenamedir); //var_dump($modulenamedir);
if (! dol_is_dir($modulenamedir)) if (! dol_is_dir($modulenamedir))
{ {
$modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example .../htdocs/mymodule
//var_dump($modulenamedir); //var_dump($modulenamedir);
if (! dol_is_dir($modulenamedir)) if (! dol_is_dir($modulenamedir))
{ {
@ -195,10 +195,16 @@ if ($action=='install')
} }
} }
if (! $error)
{
// TODO Make more test
}
// Now we install the module
if (! $error) if (! $error)
{ {
//var_dump($dirins); //var_dump($dirins);
@dol_delete_dir_recursive($dirins.'/'.$modulename); @dol_delete_dir_recursive($dirins.'/'.$modulename); // delete the zip file
dol_syslog("Uncompress of module file is a success. We copy it from ".$modulenamedir." into target dir ".$dirins.'/'.$modulename); dol_syslog("Uncompress of module file is a success. We copy it from ".$modulenamedir." into target dir ".$dirins.'/'.$modulename);
$result=dolCopyDir($modulenamedir, $dirins.'/'.$modulename, '0444', 1); $result=dolCopyDir($modulenamedir, $dirins.'/'.$modulename, '0444', 1);
if ($result <= 0) if ($result <= 0)

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012-2107 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012-2107 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -279,6 +280,12 @@ if ($action == 'edit') // Edit
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0, 1); print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0, 1);
print '</td></tr>'; print '</td></tr>';
//Invert sender and recipient
print '<tr class="oddeven"><td>'.$langs->trans("SwapSenderAndRecipientOnPDF").'</td><td>';
print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))?$conf->global->MAIN_INVERT_SENDER_RECIPIENT:0, 1);
print '</td></tr>';
// Place customer adress to the ISO location // Place customer adress to the ISO location
print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';

View File

@ -522,9 +522,9 @@ if ($resql)
$nb=$obj->nb; $nb=$obj->nb;
if ($nb > $limitforoptim) if ($nb > $limitforoptim)
{ {
if (empty($conf->global->THIRDPARTY_DONOTSEARCH_ANYWHERE)) if (empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE))
{ {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseSearchOptim", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'THIRDPARTY_DONOTSEARCH_ANYWHERE'); print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseSearchOptim", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'COMPANY_DONOTSEARCH_ANYWHERE');
} }
else else
{ {

View File

@ -50,14 +50,23 @@ if (! $user->admin)
if ($action == 'delete') if ($action == 'delete')
{ {
$file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha')))
$ret=dol_delete_file($file, 1); {
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); $ret=dol_delete_file($file, 1);
$action=''; if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
else
{
$file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha'));
$ret=dol_delete_file($file, 1);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
$action='';
} }
/* /*
* View * View
*/ */
@ -446,8 +455,10 @@ print "\n";
<br> <br>
<div class="center"><input type="submit" class="button" <div class="center">
value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo" /><br> <input type="submit" class="button reposition" value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo">
<input type="hidden" name="page_y" value="<?php echo GETPOST('page_y', 'int'); ?>">
<br>
<br> <br>
<?php <?php
@ -459,7 +470,7 @@ if (! empty($_SESSION["commandbackuplastdone"]))
//print $paramclear; //print $paramclear;
// Now run command and show result // Now show result
print '<b>'.$langs->trans("BackupResult").':</b> '; print '<b>'.$langs->trans("BackupResult").':</b> ';
print $_SESSION["commandbackupresult"]; print $_SESSION["commandbackupresult"];
@ -598,9 +609,6 @@ print '<br>';
</fieldset> </fieldset>
</form> </form>
<?php <?php
// End of page // End of page

View File

@ -118,14 +118,14 @@ function create_script_table($list)
{ {
global $sortby,$langs; global $sortby,$langs;
if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { if (GETPOT('order', 'alpha') == "asc" || GETPOST('order', 'alpha') == "desc") {
$order = GETPOST('order'); $order = GETPOST('order', 'alpha');
} else { } else {
$order = "asc"; $order = "asc";
} }
if (GETPOST('order')) { if (GETPOST('order', 'alpha')) {
switch (GETPOST('order')) { switch (GETPOST('order', 'alpha')) {
case "mtime": case "mtime":
case "size": case "size":
case "reloads": case "reloads":

View File

@ -50,7 +50,7 @@ if (! $user->admin) accessforbidden();
if ($file && ! $what) if ($file && ! $what)
{ {
//print DOL_URL_ROOT.'/dolibarr_export.php'; //print DOL_URL_ROOT.'/dolibarr_export.php';
header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod")))); header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int')?'&page_y='.GETPOST('page_y', 'int'):''));
exit; exit;
} }
@ -122,25 +122,15 @@ $utils = new Utils($db);
// MYSQL // MYSQL
if ($what == 'mysql') if ($what == 'mysql')
{ {
$cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg
$cmddump=dol_sanitizePathName($cmddump); $cmddump=dol_sanitizePathName($cmddump);
if (! empty($dolibarr_main_restrict_os_commands)) if (! empty($dolibarr_main_restrict_os_commands))
{ {
$arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands);
$ok=0;
dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump);
foreach($arrayofallowedcommand as $allowedcommand) $basenamecmddump=basename($cmddump);
{ if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command
$basenamecmddump=basename($cmddump);
if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command
{
$ok=1;
break;
}
}
if (! $ok)
{ {
$errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands');
} }
@ -176,6 +166,18 @@ if ($what == 'postgresql')
$cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg
$cmddump=dol_sanitizePathName($cmddump); $cmddump=dol_sanitizePathName($cmddump);
/* Not required, the command is output on screen but not ran for pgsql
if (! empty($dolibarr_main_restrict_os_commands))
{
$arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands);
dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump);
$basenamecmddump=basename($cmddump);
if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command
{
$errormsg=$langs->trans('CommandIsNotInsideAllowedCommands');
}
} */
if (! $errormsg && $cmddump) if (! $errormsg && $cmddump)
{ {
dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity);
@ -193,7 +195,6 @@ if ($what == 'postgresql')
} }
if ($errormsg) if ($errormsg)
{ {
setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors');
@ -230,8 +231,8 @@ $result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/
print '<br>'; print '<br>';
*/ */
// Redirect t backup page // Redirect to backup page
header("Location: dolibarr_export.php"); header("Location: dolibarr_export.php".(GETPOST('page_y', 'int')?'?page_y='.GETPOST('page_y', 'int'):''));
$time_end = time(); $time_end = time();

View File

@ -56,11 +56,12 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield="dateevent"; if (! $sortfield) $sortfield="dateevent";
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
$search_code = GETPOST("search_code"); $search_code = GETPOST("search_code", "alpha");
$search_ip = GETPOST("search_ip"); $search_ip = GETPOST("search_ip", "alpha");
$search_user = GETPOST("search_user"); $search_user = GETPOST("search_user", "alpha");
$search_desc = GETPOST("search_desc"); $search_desc = GETPOST("search_desc", "alpha");
$search_ua = GETPOST("search_ua"); $search_ua = GETPOST("search_ua", "none");
$search_prefix_session = GETPOST("search_prefix_session", "none");
if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
else $date_start=-1; else $date_start=-1;
@ -91,6 +92,8 @@ $date_endday = $tmp['mday'];
$date_endmonth = $tmp['mon']; $date_endmonth = $tmp['mon'];
$date_endyear = $tmp['year']; $date_endyear = $tmp['year'];
$arrayfields=array();
/* /*
* Actions * Actions
@ -108,6 +111,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_user=''; $search_user='';
$search_desc=''; $search_desc='';
$search_ua=''; $search_ua='';
$search_prefix_session='';
} }
// Purge audit events // Purge audit events
@ -136,6 +140,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin)
$securityevent->type='SECURITY_EVENTS_PURGE'; $securityevent->type='SECURITY_EVENTS_PURGE';
$securityevent->dateevent=$now; $securityevent->dateevent=$now;
$securityevent->description=$text; $securityevent->description=$text;
$result=$securityevent->create($user); $result=$securityevent->create($user);
if ($result > 0) if ($result > 0)
{ {
@ -163,7 +168,7 @@ $userstatic=new User($db);
$usefilter=0; $usefilter=0;
$sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,"; $sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
$sql.= " e.fk_user, e.description,"; $sql.= " e.fk_user, e.description, e.prefix_session,";
$sql.= " u.login"; $sql.= " u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $sql.= " FROM ".MAIN_DB_PREFIX."events as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
@ -175,6 +180,7 @@ if ($search_ip) { $usefilter++; $sql.=natural_search("e.ip", $search_ip, 0); }
if ($search_user) { $usefilter++; $sql.=natural_search("u.login", $search_user, 0); } if ($search_user) { $usefilter++; $sql.=natural_search("u.login", $search_user, 0); }
if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); } if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); }
if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); } if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); }
if ($search_prefix_session) { $usefilter++; $sql.=natural_search("e.prefix_session", $search_prefix_session, 0); }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
@ -207,6 +213,7 @@ if ($result)
if ($search_user) $param.='&search_user='.urlencode($search_user); if ($search_user) $param.='&search_user='.urlencode($search_user);
if ($search_desc) $param.='&search_desc='.urlencode($search_desc); if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_ua) $param.='&search_ua='.urlencode($search_ua); if ($search_ua) $param.='&search_ua='.urlencode($search_ua);
if ($search_prefix_sessiona) $param.='&search_prefix_session='.urlencode($search_prefix_session);
if ($date_startmonth) $param.= "&date_startmonth=".urlencode($date_startmonth); if ($date_startmonth) $param.= "&date_startmonth=".urlencode($date_startmonth);
if ($date_startday) $param.= "&date_startday=".urlencode($date_startday); if ($date_startday) $param.= "&date_startday=".urlencode($date_startday);
if ($date_startyear) $param.= "&date_startyear=".urlencode($date_startyear); if ($date_startyear) $param.= "&date_startyear=".urlencode($date_startyear);
@ -239,22 +246,36 @@ if ($result)
print '<td class="liste_titre" width="15%">'.$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0).'</td>'; print '<td class="liste_titre" width="15%">'.$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0).'</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="10" name="search_code" value="'.$search_code.'">'; print '<input class="flat maxwidth100" type="text" name="search_code" value="'.$search_code.'">';
print '</td>'; print '</td>';
// IP // IP
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="10" name="search_ip" value="'.$search_ip.'">'; print '<input class="flat maxwidth100" type="text" name="search_ip" value="'.$search_ip.'">';
print '</td>'; print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="10" name="search_user" value="'.$search_user.'">'; print '<input class="flat maxwidth100" type="text" name="search_user" value="'.$search_user.'">';
print '</td>'; print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
//print '<input class="flat" type="text" size="10" name="search_desc" value="'.$search_desc.'">'; //print '<input class="flat maxwidth100" type="text" size="10" name="search_desc" value="'.$search_desc.'">';
print '</td>'; print '</td>';
if (! empty($arrayfields['e.user_agent']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.$search_ua.'">';
print '</td>';
}
if (! empty($arrayfields['e.prefix_session']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.$search_prefix_session.'">';
print '</td>';
}
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterAndCheckAddButtons(0); $searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
@ -264,11 +285,19 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['e.user_agent']['checked']))
{
print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder);
}
if (! empty($arrayfields['e.prefix_session']['checked']))
{
print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder);
}
print_liste_field_titre(''); print_liste_field_titre('');
print "</tr>\n"; print "</tr>\n";
@ -312,9 +341,26 @@ if ($result)
print $text; print $text;
print '</td>'; print '</td>';
if (! empty($arrayfields['e.user_agent']['checked']))
{
// User agent
print '<td>';
print $obj->user_agent;
print '</td>';
}
if (! empty($arrayfields['e.prefix_session']['checked']))
{
// User agent
print '<td>';
print $obj->prefix_session;
print '</td>';
}
// More informations // More informations
print '<td class="right">'; print '<td class="right">';
$htmltext='<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent?$obj->user_agent:$langs->trans("Unknown")); $htmltext='<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent?$obj->user_agent:$langs->trans("Unknown"));
$htmltext.='<br><b>'.$langs->trans("PrefixSession").'</b>: '.($obj->prefix_session?$obj->prefix_session:$langs->trans("Unknown"));
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext);
print '</td>'; print '</td>';

View File

@ -618,14 +618,14 @@ if ($id)
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print '<a href="'.$url.'action='.$acts[$obj->status].'">'.$actl[$obj->status].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status?1:0)].'">'.$actl[($obj->status?1:0)].'</a>';
print "</td>"; print "</td>";
// Modify link // Modify link
print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>'; print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
// Delete link // Delete link
if ($iserasable) print '<td align="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>'; if ($iserasable) print '<td align="center"><a class="reposition" href="'.$url.'action=delete">'.img_delete().'</a></td>';
else print '<td align="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>'; else print '<td align="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -78,6 +78,12 @@ if ($action == 'setproductionmode')
} }
} }
if ($action == 'save')
{
dolibarr_set_const($db, 'API_RESTRICT_ON_IP', GETPOST('API_RESTRICT_ON_IP', 'alpha'));
}
dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge
@ -93,37 +99,50 @@ print load_fiche_titre($langs->trans("ApiSetup"), $linkback, 'title_setup');
print $langs->trans("ApiDesc")."<br>\n"; print $langs->trans("ApiDesc")."<br>\n";
print "<br>\n"; print "<br>\n";
//print '<form name="apisetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="save">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print "<td>".$langs->trans("Parameter")."</td>"; print "<td>".$langs->trans("Parameter")."</td>";
print '<td align="center">'.$langs->trans("Value")."</td>"; print '<td>'.$langs->trans("Value")."</td>";
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "</tr>"; print "</tr>";
print '<tr class="impair">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("ApiProductionMode").'</td>'; print '<td>'.$langs->trans("ApiProductionMode").'</td>';
$production_mode=(empty($conf->global->API_PRODUCTION_MODE)?false:true); $production_mode=(empty($conf->global->API_PRODUCTION_MODE)?false:true);
if ($production_mode) if ($production_mode)
{ {
print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=0">'; print '<td><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} }
else else
{ {
print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=1">'; print '<td><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("RESTRICT_API_ON_IP").'</td>';
print '<td><input type="text" name="API_RESTRICT_ON_IP" value="'.dol_escape_htmltag($conf->global->API_RESTRICT_ON_IP).'"></td>';
print '<td>';
print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></td>';
print '</td>';
print '</tr>';
print '</table>'; print '</table>';
print '<br><br>'; print '<br><br>';
print '</form>';
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file

View File

@ -32,7 +32,7 @@ class DolibarrApi
/** /**
* @var DoliDb $db Database object * @var DoliDb $db Database object
*/ */
static protected $db; protected static $db;
/** /**
* @var Restler $r Restler object * @var Restler $r Restler object

View File

@ -56,7 +56,7 @@ class Documents extends DolibarrApi
* Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for * Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for
* internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead). * internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead).
* *
* @param string $module_part Name of module or area concerned by file download ('facture', ...) * @param string $modulepart Name of module or area concerned by file download ('facture', ...)
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf)
* @return array List of documents * @return array List of documents
* *
@ -67,11 +67,11 @@ class Documents extends DolibarrApi
* *
* @url GET /download * @url GET /download
*/ */
public function index($module_part, $original_file = '') public function index($modulepart, $original_file = '')
{ {
global $conf, $langs; global $conf, $langs;
if (empty($module_part)) { if (empty($modulepart)) {
throw new RestException(400, 'bad value for parameter modulepart'); throw new RestException(400, 'bad value for parameter modulepart');
} }
if (empty($original_file)) { if (empty($original_file)) {
@ -81,7 +81,7 @@ class Documents extends DolibarrApi
//--- Finds and returns the document //--- Finds and returns the document
$entity=$conf->entity; $entity=$conf->entity;
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file']; $original_file = $check_access['original_file'];
@ -98,6 +98,7 @@ class Documents extends DolibarrApi
if (! file_exists($original_file_osencoded)) if (! file_exists($original_file_osencoded))
{ {
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
throw new RestException(404, 'File not found'); throw new RestException(404, 'File not found');
} }
@ -111,7 +112,7 @@ class Documents extends DolibarrApi
* *
* Test sample 1: { "module_part": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }. * Test sample 1: { "module_part": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }.
* *
* @param string $module_part Name of module or area concerned by file download ('invoice', 'order', ...). * @param string $modulepart Name of module or area concerned by file download ('invoice', 'order', ...).
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf).
* @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template). * @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template).
* @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language). * @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language).
@ -126,11 +127,11 @@ class Documents extends DolibarrApi
* *
* @url PUT /builddoc * @url PUT /builddoc
*/ */
public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') public function builddoc($modulepart, $original_file = '', $doctemplate = '', $langcode = '')
{ {
global $conf, $langs; global $conf, $langs;
if (empty($module_part)) { if (empty($modulepart)) {
throw new RestException(400, 'bad value for parameter modulepart'); throw new RestException(400, 'bad value for parameter modulepart');
} }
if (empty($original_file)) { if (empty($original_file)) {
@ -147,7 +148,7 @@ class Documents extends DolibarrApi
//--- Finds and returns the document //--- Finds and returns the document
$entity=$conf->entity; $entity=$conf->entity;
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write');
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file']; $original_file = $check_access['original_file'];
@ -166,7 +167,7 @@ class Documents extends DolibarrApi
$templateused=''; $templateused='';
if ($module_part == 'facture' || $module_part == 'invoice') if ($modulepart == 'facture' || $modulepart == 'invoice')
{ {
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$this->invoice = new Facture($this->db); $this->invoice = new Facture($this->db);
@ -181,7 +182,7 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Error generating document'); throw new RestException(500, 'Error generating document');
} }
} }
elseif ($module_part == 'commande' || $module_part == 'order') elseif ($modulepart == 'commande' || $modulepart == 'order')
{ {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$this->order = new Commande($this->db); $this->order = new Commande($this->db);
@ -195,7 +196,7 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Error generating document'); throw new RestException(500, 'Error generating document');
} }
} }
elseif ($module_part == 'propal' || $module_part == 'proposal') elseif ($modulepart == 'propal' || $modulepart == 'proposal')
{ {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$this->propal = new Propal($this->db); $this->propal = new Propal($this->db);
@ -368,7 +369,7 @@ class Documents extends DolibarrApi
throw new RestException(404, 'Product not found'); throw new RestException(404, 'Product not found');
} }
$upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'product'); $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
} }
elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event')
{ {

View File

@ -57,12 +57,13 @@ class Login
*/ */
public function index($login, $password, $entity = '', $reset = 0) public function index($login, $password, $entity = '', $reset = 0)
{ {
global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
// Authentication mode // TODO Remove the API login. The token must be generated from backoffice only.
if (empty($dolibarr_main_authentication))
$dolibarr_main_authentication = 'http,dolibarr'; // Authentication mode
if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'dolibarr';
// Authentication mode: forceuser // Authentication mode: forceuser
if ($dolibarr_main_authentication == 'forceuser') if ($dolibarr_main_authentication == 'forceuser')
{ {
@ -73,6 +74,7 @@ class Login
throw new RestException(403, "Your instance is set to use the automatic login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode."); throw new RestException(403, "Your instance is set to use the automatic login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode.");
} }
} }
// Set authmode // Set authmode
$authmode = explode(',', $dolibarr_main_authentication); $authmode = explode(',', $dolibarr_main_authentication);
@ -83,7 +85,7 @@ class Login
if ($entity == '') $entity=1; if ($entity == '') $entity=1;
include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
$login = checkLoginPassEntity($login, $password, $entity, $authmode); $login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api');
if (empty($login)) if (empty($login))
{ {
throw new RestException(403, 'Access denied'); throw new RestException(403, 'Access denied');

View File

@ -24,6 +24,8 @@
* \file htdocs/api/index.php * \file htdocs/api/index.php
*/ */
use Luracast\Restler\Format\UploadFormat;
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
@ -117,6 +119,21 @@ $api->r->addAuthenticationClass('DolibarrApiAccess', '');
UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream');
// Restrict API to some IPs
if (! empty($conf->global->API_RESTRICT_ON_IP))
{
$allowedip=explode(' ', $conf->global->API_RESTRICT_ON_IP);
$ipremote = getUserRemoteIP();
if (! in_array($ipremote, $allowedip))
{
dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP);
print 'APIs are not allowed from the IP '.$ipremote;
header('HTTP/1.1 503 API not allowed from your IP '.$ipremote);
//print $conf->global->API_RESTRICT_ON_IP;
exit(0);
}
}
// Call Explorer file for all APIs definitions (this part is slow) // Call Explorer file for all APIs definitions (this part is slow)
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
@ -136,6 +153,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' ||
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
$regmod=array();
if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod))
{ {
$module = strtolower($regmod[1]); $module = strtolower($regmod[1]);
@ -165,6 +183,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' ||
{ {
if ($file_searched == 'api_access.class.php') continue; if ($file_searched == 'api_access.class.php') continue;
$regapi = array();
if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi))
{ {
$classname = ucwords($regapi[1]); $classname = ucwords($regapi[1]);
@ -204,6 +223,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' ||
} }
// Call one APIs or one definition of an API // Call one APIs or one definition of an API
$regbis = array();
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root')))
{ {
$module = $reg[1]; $module = $reg[1];
@ -253,7 +273,6 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
$api->r->addAPIClass($classname); $api->r->addAPIClass($classname);
} }
// TODO If not found, redirect to explorer
//var_dump($api->r->apiVersionMap); //var_dump($api->r->apiVersionMap);
//exit; //exit;

View File

@ -515,6 +515,7 @@ class BOM extends CommonObject
public function valid($user, $notrigger = 0) public function valid($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0; $error=0;
@ -582,13 +583,18 @@ class BOM extends CommonObject
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref) // Now we rename also files into index
// in order not to lose the attachments $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'bom/".$this->db->escape($this->newref)."'";
$oldref = dol_sanitizeFileName($this->ref); $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->bom->dir_output.'/'.$oldref; $dirsource = $conf->bom->dir_output.'/'.$oldref;
$dirdest = $conf->bom->dir_output.'/'.$newref; $dirdest = $conf->bom->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (! $error && file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);

View File

@ -79,16 +79,6 @@ if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_
} }
/*
if (! empty($_POST['txtUsername']) && ! empty($conf->banque->enabled) && (empty($conf_fkaccount_cash) && empty($conf_fkaccount_cheque) && empty($conf_fkaccount_cb)))
{
$langs->load("errors");
$retour=$langs->trans("ErrorModuleSetupNotComplete");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid);
exit;
}
*/
// Check password // Check password
$auth = new Auth($db); $auth = new Auth($db);
$retour = $auth->verif($username, $password); $retour = $auth->verif($username, $password);

View File

@ -165,7 +165,7 @@ $langs->loadLangs(array("main","bills","cashdesk"));
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0)
{ {
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
} }
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />'; else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
print '</div>'; print '</div>';
@ -173,7 +173,7 @@ $langs->loadLangs(array("main","bills","cashdesk"));
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0)
{ {
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
} }
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />'; else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
print '</div>'; print '</div>';
@ -181,7 +181,7 @@ $langs->loadLangs(array("main","bills","cashdesk"));
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0)
{ {
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />';
} }
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />'; else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
print '</div>'; print '</div>';

View File

@ -168,287 +168,8 @@ if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5p
//var_dump($objectpage);exit; //var_dump($objectpage);exit;
print '<div class="centpercent websitebar">'; print '<div class="centpercent websitebar">';
if (count($object->records) > 0)
{
// ***** Part for web sites
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("WebSite").': ';
print '</div>';
// List of websites
print '<div class="websiteselection">';
$out='';
$out.='<select name="website" class="minwidth100" id="website">';
if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>';
// Loop on each sites
$i=0;
foreach($object->records as $key => $valwebsite)
{
if (empty($website)) $website=$valwebsite->ref;
$out.='<option value="'.$valwebsite->ref.'"';
if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valwebsite->ref;
$out.='</option>';
$i++;
}
$out.='</select>';
$out.=ajax_combobox('website');
print $out;
print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
if ($website)
{
$virtualurl='';
$dataroot=DOL_DATA_ROOT.'/collab/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
if ($website && $action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
print ' &nbsp; ';
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
}
print '</div>';
// Button for websites
print '<div class="websitetools">';
if ($action == 'preview')
{
print '<div class="websiteinputurl">';
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext);
print '</div>';
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/collab/index.php?website='.$website;
//if (! empty($object->virtualhost))
//{
print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
//}
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/collab/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>';
}
if (in_array($action, array('editcss','editmenu','create')))
{
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
// ***** Part for pages
if ($website)
{
print '</div>';
$array=$objectpage->fetchAll($object->id);
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': ';
print '</div>';
print '<div class="websiteselection">';
if ($action != 'add')
{
$out='';
$out.='<select name="pageid" id="pageid" class="minwidth200">';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id;
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
}
}
else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>';
$out.=ajax_combobox('pageid');
print $out;
}
else
{
print $langs->trans("New");
}
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array);
if ($action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($pageid > 0)
{
print ' &nbsp; ';
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageContent")).'" name="editcontent">';
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=editmeta&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageMeta")).'</a>';
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=editcontent&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageContent")).'</a>';
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
}
}
print '</div>';
print '<div class="websiteselection">';
print '</div>';
print '<div class="websitetools">';
if ($website && $pageid > 0 && $action == 'preview')
{
$websitepage = new WebSitePage($db);
$websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/collab/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">';
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext);
print '</div>';
if (! empty($object->virtualhost))
{
$urlext=$virtualurl.'/'.$pagealias.'.php';
print '<a class="websitebuttonsitepreview" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
else
{
print '<a class="websitebuttonsitepreview" id="previewpageextnoclick" href="#">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print '</a>'; // View page in new Tab
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
// TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext
}
if (! in_array($action, array('editcss','editmenu','create')))
{
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
if ($action == 'preview')
{
// Adding jquery code to change on the fly url of preview ext
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#previewsiteext,#previewpageext").click(function() {
newurl=jQuery("#previewsiteurl").val();
newpage=jQuery("#previewsiteurl").val() + "/" + jQuery("#previewpageurl").val() + ".php";
console.log("Open url "+newurl);
/* Save url */
jQuery.ajax({
method: "POST",
url: "'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
data: {
field: \'editval_virtualhost\',
element: \'websites\',
table_element: \'website\',
fk_element: '.$object->id.',
value: newurl,
},
context: document.body
});
jQuery("#previewsiteext").attr("href",newurl);
jQuery("#previewpageext").attr("href",newpage);
});
});
</script>';
}
}
}
}
else
{
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';
$action='';
}
print '</div>';
$head = array();
if ($action == 'editcontent')
{
/*
* Editing global variables not related to a specific theme
*/
$csscontent = @file_get_contents($filecss);
$contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit.=$csscontent;
$contentforedit.='</style>'."\n";*/
$contentforedit .= $objectpage->content;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('PAGE_CONTENT', $contentforedit, '', 500, 'Full', '', true, true, true, ROWS_5, '90%');
$doleditor->Create(0, '', false);
}
print "</div>\n</form>\n"; print "</div>\n</form>\n";

View File

@ -1103,6 +1103,7 @@ class ActionComm extends CommonObject
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay = $conf->agenda->warning_delay/60/60/24; $response->warning_delay = $conf->agenda->warning_delay/60/60/24;
$response->label = $langs->trans("ActionsToDo"); $response->label = $langs->trans("ActionsToDo");
$response->labelShort = $langs->trans("ActionsToDoShort");
$response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&amp;status=todo&amp;mainmenu=agenda'; $response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&amp;status=todo&amp;mainmenu=agenda';
if ($user->rights->agenda->allactions->read) $response->url.='&amp;filtert=-1'; if ($user->rights->agenda->allactions->read) $response->url.='&amp;filtert=-1';
$response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"');
@ -1286,8 +1287,10 @@ class ActionComm extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id)) if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id))
{
$option = 'nolink'; $option = 'nolink';
}
$label = $this->label; $label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility if (empty($label)) $label=$this->libelle; // For backward compatibility

View File

@ -380,7 +380,6 @@ if (empty($reshook))
} }
} else { } else {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
$object->ref_client = GETPOST('ref_client'); $object->ref_client = GETPOST('ref_client');
$object->datep = $datep; $object->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;

View File

@ -6,7 +6,7 @@
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2019 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2017 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2010-2017 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
@ -530,11 +530,11 @@ class Propal extends CommonObject
$pu_ht_devise = $tabprice[19]; $pu_ht_devise = $tabprice[19];
// Rang to use // Rang to use
$rangtouse = $rang; $ranktouse = $rang;
if ($rangtouse == -1) if ($ranktouse == -1)
{ {
$rangmax = $this->line_max($fk_parent_line); $rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1; $ranktouse = $rangmax + 1;
} }
// TODO A virer // TODO A virer
@ -568,7 +568,7 @@ class Propal extends CommonObject
$this->line->fk_remise_except=$fk_remise_except; $this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent; $this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht; $this->line->subprice=$pu_ht;
$this->line->rang=$rangtouse; $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht; $this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva; $this->line->total_tva=$total_tva;
@ -890,7 +890,6 @@ class Propal extends CommonObject
$now=dol_now(); $now=dol_now();
// Clean parameters // Clean parameters
if (empty($this->entity)) $this->entity = $conf->entity;
if (empty($this->date)) $this->date=$this->datep; if (empty($this->date)) $this->date=$this->datep;
$this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
if (empty($this->availability_id)) $this->availability_id=0; if (empty($this->availability_id)) $this->availability_id=0;
@ -1000,7 +999,7 @@ class Propal extends CommonObject
$sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".(int) $this->fk_incoterms; $sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$this->entity; $sql.= ", ".setEntity($this);
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx; $sql.= ", ".(double) $this->multicurrency_tx;
@ -1056,14 +1055,6 @@ class Propal extends CommonObject
} }
} }
// Add linked object (deprecated, use ->linkedObjectsIds instead)
if (! $error && $this->origin && $this->origin_id)
{
dol_syslog('Deprecated use of linked object, use ->linkedObjectsIds instead', LOG_WARNING);
$ret = $this->add_object_linked();
if (! $ret) dol_print_error($this->db);
}
/* /*
* Insertion du detail des produits dans la base * Insertion du detail des produits dans la base
* Insert products detail in database * Insert products detail in database
@ -1091,7 +1082,7 @@ class Propal extends CommonObject
$vatrate = $line->tva_tx; $vatrate = $line->tva_tx;
if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')';
$result = $this->addline( $result = $this->addline(
$line->desc, $line->desc,
$line->subprice, $line->subprice,
$line->qty, $line->qty,
@ -1138,7 +1129,7 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address;
$sql.= " WHERE ref = '".$this->db->escape($this->ref)."'"; $sql.= " WHERE ref = '".$this->db->escape($this->ref)."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".setEntity($this);
$result=$this->db->query($sql); $result=$this->db->query($sql);
} }
@ -1749,10 +1740,10 @@ class Propal extends CommonObject
*/ */
public function valid($user, $notrigger = 0) public function valid($user, $notrigger = 0)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0; $error=0;
// Protection // Protection
@ -1818,14 +1809,18 @@ class Propal extends CommonObject
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// Rename of propal directory ($this->ref = old ref, $num = new ref) // Now we rename also files into index
// to not lose the linked files $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'propale/".$this->db->escape($this->newref)."'";
$sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'propale/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->propal->multidir_output[$this->entity].'/'.$oldref; $dirsource = $conf->propal->multidir_output[$this->entity].'/'.$oldref;
$dirdest = $conf->propal->multidir_output[$this->entity].'/'.$newref; $dirdest = $conf->propal->multidir_output[$this->entity].'/'.$newref;
if (! $error && file_exists($dirsource))
if (file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
@ -3273,21 +3268,24 @@ class Propal extends CommonObject
$delay_warning = 0; $delay_warning = 0;
$statut = 0; $statut = 0;
$label = ''; $label = $labelShort = '';
if ($mode == 'opened') { if ($mode == 'opened') {
$delay_warning=$conf->propal->cloture->warning_delay; $delay_warning=$conf->propal->cloture->warning_delay;
$statut = self::STATUS_VALIDATED; $statut = self::STATUS_VALIDATED;
$label = $langs->trans("PropalsToClose"); $label = $langs->trans("PropalsToClose");
$labelShort = $langs->trans("ToAcceptRefuse");
} }
if ($mode == 'signed') { if ($mode == 'signed') {
$delay_warning=$conf->propal->facturation->warning_delay; $delay_warning=$conf->propal->facturation->warning_delay;
$statut = self::STATUS_SIGNED; $statut = self::STATUS_SIGNED;
$label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered $label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered
$labelShort = $langs->trans("ToBill");
} }
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay = $delay_warning/60/60/24; $response->warning_delay = $delay_warning/60/60/24;
$response->label = $label; $response->label = $label;
$response->labelShort = $labelShort;
$response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals'; $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals';
$response->url_late = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals&sortfield=p.datep&sortorder=asc'; $response->url_late = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals&sortfield=p.datep&sortorder=asc';
$response->img = img_object('', "propal"); $response->img = img_object('', "propal");
@ -3512,7 +3510,7 @@ class Propal extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Proposal"));
return ""; return "";
} }
} }

View File

@ -168,6 +168,7 @@ $arrayfields=array(
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
); );
// Extra fields // Extra fields
@ -269,10 +270,10 @@ $sql.= " typent.code as typent_code,";
$sql.= " ava.rowid as availability,"; $sql.= " ava.rowid as availability,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
$sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; $sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
$sql.= ' u.login'; $sql.= ' u.login';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
@ -688,6 +689,12 @@ if ($resql)
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
// Date cloture
if (! empty($arrayfields['p.date_cloture']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status // Status
if (! empty($arrayfields['p.fk_statut']['checked'])) if (! empty($arrayfields['p.fk_statut']['checked']))
{ {
@ -735,6 +742,7 @@ if ($resql)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print '</tr>'."\n"; print '</tr>'."\n";
@ -1054,7 +1062,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook // Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation
@ -1073,6 +1081,14 @@ if ($resql)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Date cloture
if (! empty($arrayfields['p.date_cloture']['checked']))
{
print '<td align="center" class="nowrap">';
print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status // Status
if (! empty($arrayfields['p.fk_statut']['checked'])) if (! empty($arrayfields['p.fk_statut']['checked']))
{ {

View File

@ -96,9 +96,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ordercard','globalcard')); $hookmanager->initHooks(array('ordercard','globalcard'));
$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php $usercanread = $user->rights->commande->lire;
$permissiondellink = $user->rights->commande->creer; // Used by the include of actions_dellink.inc.php $usercancreate = $user->rights->commande->creer;
$permissionedit = $user->rights->commande->creer; // Used by the include of actions_lineupdown.inc.php $usercanclose = $user->rights->commande->cloturer;
$usercandelete = $user->rights->commande->supprimer;
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)));
$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send);
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$permissionedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
/* /*
@ -129,7 +137,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate)
{ {
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
@ -159,7 +167,7 @@ if (empty($reshook))
} }
// Reopen a closed order // Reopen a closed order
elseif ($action == 'reopen' && $user->rights->commande->creer) elseif ($action == 'reopen' && $usercancreate)
{ {
if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED)
{ {
@ -176,7 +184,7 @@ if (empty($reshook))
} }
// Remove order // Remove order
elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete)
{ {
$result = $object->delete($user); $result = $object->delete($user);
if ($result > 0) if ($result > 0)
@ -191,7 +199,7 @@ if (empty($reshook))
} }
// Remove a product line // Remove a product line
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
{ {
$result = $object->deleteline($user, $lineid); $result = $object->deleteline($user, $lineid);
if ($result > 0) if ($result > 0)
@ -222,13 +230,13 @@ if (empty($reshook))
} }
// Link to a project // Link to a project
elseif ($action == 'classin' && $user->rights->commande->creer) elseif ($action == 'classin' && $usercancreate)
{ {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
} }
// Add order // Add order
elseif ($action == 'add' && $user->rights->commande->creer) elseif ($action == 'add' && $usercancreate)
{ {
$datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
@ -484,7 +492,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'classifybilled' && $user->rights->commande->creer) elseif ($action == 'classifybilled' && $usercancreate)
{ {
$ret=$object->classifyBilled($user); $ret=$object->classifyBilled($user);
@ -492,7 +500,7 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action == 'classifyunbilled' && $user->rights->commande->creer) elseif ($action == 'classifyunbilled' && $usercancreate)
{ {
$ret=$object->classifyUnBilled(); $ret=$object->classifyUnBilled();
if ($ret < 0) { if ($ret < 0) {
@ -501,7 +509,7 @@ if (empty($reshook))
} }
// Positionne ref commande client // Positionne ref commande client
elseif ($action == 'setref_client' && $user->rights->commande->creer) { elseif ($action == 'setref_client' && $usercancreate) {
$result = $object->set_ref_client($user, GETPOST('ref_client')); $result = $object->set_ref_client($user, GETPOST('ref_client'));
if ($result < 0) if ($result < 0)
{ {
@ -509,7 +517,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setremise' && $user->rights->commande->creer) { elseif ($action == 'setremise' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise')); $result = $object->set_remise($user, GETPOST('remise'));
if ($result < 0) if ($result < 0)
{ {
@ -517,7 +525,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setabsolutediscount' && $user->rights->commande->creer) { elseif ($action == 'setabsolutediscount' && $usercancreate) {
if (GETPOST('remise_id')) { if (GETPOST('remise_id')) {
if ($object->id > 0) { if ($object->id > 0) {
$object->insert_discount(GETPOST('remise_id')); $object->insert_discount(GETPOST('remise_id'));
@ -527,7 +535,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setdate' && $user->rights->commande->creer) { elseif ($action == 'setdate' && $usercancreate) {
// print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year'));
@ -537,7 +545,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setdate_livraison' && $user->rights->commande->creer) { elseif ($action == 'setdate_livraison' && $usercancreate) {
// print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
@ -547,35 +555,35 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setmode' && $user->rights->commande->creer) { elseif ($action == 'setmode' && $usercancreate) {
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
// Multicurrency Code // Multicurrency Code
elseif ($action == 'setmulticurrencycode' && $user->rights->commande->creer) { elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
} }
// Multicurrency rate // Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) { elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
} }
elseif ($action == 'setavailability' && $user->rights->commande->creer) { elseif ($action == 'setavailability' && $usercancreate) {
$result = $object->availability(GETPOST('availability_id')); $result = $object->availability(GETPOST('availability_id'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
elseif ($action == 'setdemandreason' && $user->rights->commande->creer) { elseif ($action == 'setdemandreason' && $usercancreate) {
$result = $object->demand_reason(GETPOST('demand_reason_id')); $result = $object->demand_reason(GETPOST('demand_reason_id'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
elseif ($action == 'setconditions' && $user->rights->commande->creer) { elseif ($action == 'setconditions' && $usercancreate) {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0) { if ($result < 0) {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
@ -607,7 +615,7 @@ if (empty($reshook))
} }
// bank account // bank account
elseif ($action == 'setbankaccount' && $user->rights->commande->creer) { elseif ($action == 'setbankaccount' && $usercancreate) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int')); $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -615,7 +623,7 @@ if (empty($reshook))
} }
// shipping method // shipping method
elseif ($action == 'setshippingmethod' && $user->rights->commande->creer) { elseif ($action == 'setshippingmethod' && $usercancreate) {
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -623,23 +631,23 @@ if (empty($reshook))
} }
// warehouse // warehouse
elseif ($action == 'setwarehouse' && $user->rights->commande->creer) { elseif ($action == 'setwarehouse' && $usercancreate) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action == 'setremisepercent' && $user->rights->commande->creer) { elseif ($action == 'setremisepercent' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise_percent')); $result = $object->set_remise($user, GETPOST('remise_percent'));
} }
elseif ($action == 'setremiseabsolue' && $user->rights->commande->creer) { elseif ($action == 'setremiseabsolue' && $usercancreate) {
$result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); $result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
} }
// Add a new line // Add a new line
elseif ($action == 'addline' && $user->rights->commande->creer) elseif ($action == 'addline' && $usercancreate)
{ {
$langs->load('errors'); $langs->load('errors');
$error = 0; $error = 0;
@ -1002,7 +1010,7 @@ if (empty($reshook))
/* /*
* Update a line * Update a line
*/ */
elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('save')) elseif ($action == 'updateline' && $usercancreate && GETPOST('save'))
{ {
// Clean parameters // Clean parameters
$date_start=''; $date_start='';
@ -1136,15 +1144,12 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition
exit(); exit();
} }
elseif ($action == 'confirm_validate' && $confirm == 'yes' && elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
((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)))
)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -1198,7 +1203,7 @@ if (empty($reshook))
} }
// Go back to draft status // Go back to draft status
elseif ($action == 'confirm_modif' && $user->rights->commande->creer) { elseif ($action == 'confirm_modif' && $usercancreate) {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
@ -1246,17 +1251,14 @@ if (empty($reshook))
} }
} }
elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) {
$result = $object->cloture($user); $result = $object->cloture($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action == 'confirm_cancel' && $confirm == 'yes' && elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate)
((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)))
)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -1313,7 +1315,7 @@ if (empty($reshook))
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }
if ($action == 'set_thirdparty' && $user->rights->commande->creer) if ($action == 'set_thirdparty' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
@ -1324,7 +1326,7 @@ if (empty($reshook))
// add lines from objectlinked // add lines from objectlinked
if($action == 'import_lines_from_object' if($action == 'import_lines_from_object'
&& $user->rights->commande->creer && $usercancreate
&& $object->statut == Commande::STATUS_DRAFT && $object->statut == Commande::STATUS_DRAFT
) )
{ {
@ -1408,8 +1410,8 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc // Actions to build doc
$upload_dir = $conf->commande->dir_output; $upload_dir = $conf->commande->multidir_output[$object->entity];
$permissioncreate = $user->rights->commande->creer; $permissioncreate = $usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails // Actions to send emails
@ -1420,7 +1422,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate)
{ {
if ($action == 'addcontact') if ($action == 'addcontact')
{ {
@ -1481,7 +1483,7 @@ $formmargin = new FormMargin($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
// Mode creation // Mode creation
if ($action == 'create' && $user->rights->commande->creer) if ($action == 'create' && $usercancreate)
{ {
print load_fiche_titre($langs->trans('CreateOrder'), '', 'title_commercial.png'); print load_fiche_titre($langs->trans('CreateOrder'), '', 'title_commercial.png');
@ -1759,6 +1761,15 @@ if ($action == 'create' && $user->rights->commande->creer)
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) { if (empty($reshook)) {
if (! empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) {
// copy from thirdparty
$tpExtrafields = new Extrafields($db);
$tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
if ($soc->fetch_optionals() > 0) {
$object->array_options = array_merge($object->array_options, $soc->array_options);
}
};
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -2072,8 +2083,8 @@ if ($action == 'create' && $user->rights->commande->creer)
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref customer // Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
@ -2082,7 +2093,7 @@ if ($action == 'create' && $user->rights->commande->creer)
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer) if ($usercancreate)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
@ -2162,7 +2173,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Date // Date
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("Date", 'date', '', $object, $editenable); print $form->editfieldkey("Date", 'date', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editdate') { if ($action == 'editdate') {
@ -2183,7 +2194,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery date planed // Delivery date planed
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editdate_livraison') { if ($action == 'editdate_livraison') {
@ -2205,7 +2216,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Shipping Method // Shipping Method
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editshippingmethod') { if ($action == 'editshippingmethod') {
@ -2223,7 +2234,7 @@ if ($action == 'create' && $user->rights->commande->creer)
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db); $formproduct=new FormProduct($db);
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editwarehouse') { if ($action == 'editwarehouse') {
@ -2237,7 +2248,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Terms of payment // Terms of payment
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editconditions') { if ($action == 'editconditions') {
@ -2251,7 +2262,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Mode of payment // Mode of payment
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editmode') { if ($action == 'editmode') {
@ -2267,7 +2278,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Multicurrency code // Multicurrency code
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
$editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencycode') { if ($action == 'editmulticurrencycode') {
@ -2280,7 +2291,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Multicurrency rate // Multicurrency rate
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
$editenable = $user->rights->commande->creer && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT; $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
@ -2301,7 +2312,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery delay // Delivery delay
print '<tr class="fielddeliverydelay"><td>'; print '<tr class="fielddeliverydelay"><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editavailability') { if ($action == 'editavailability') {
@ -2313,7 +2324,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Source reason (why we have an ordrer) // Source reason (why we have an ordrer)
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editdemandreason') { if ($action == 'editdemandreason') {
@ -2326,7 +2337,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// TODO Order mode (how we receive order). Not yet implemented // TODO Order mode (how we receive order). Not yet implemented
/* /*
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable); print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editinputmode') { if ($action == 'editinputmode') {
@ -2358,7 +2369,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Incoterms // Incoterms
if (!empty($conf->incoterm->enabled)) { if (!empty($conf->incoterm->enabled)) {
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
@ -2376,7 +2387,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Bank Account // Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) {
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editbankaccount') { if ($action == 'editbankaccount') {
@ -2500,7 +2511,7 @@ if ($action == 'create' && $user->rights->commande->creer)
/* /*
* Form to add new line * Form to add new line
*/ */
if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer && $action != 'selectlines') if ($object->statut == Commande::STATUS_DRAFT && $usercancreate && $action != 'selectlines')
{ {
if ($action != 'editline') if ($action != 'editline')
{ {
@ -2531,22 +2542,19 @@ if ($action == 'create' && $user->rights->commande->creer)
if (empty($reshook)) { if (empty($reshook)) {
// Send // Send
if ($object->statut > Commande::STATUS_DRAFT) { if ($object->statut > Commande::STATUS_DRAFT) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { if ($usercansend) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>';
} else } else
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>';
} }
// Valid // Valid
if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate)
((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)))
)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
} }
// Edit // Edit
if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->creer) { if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
} }
// Create event // Create event
@ -2594,18 +2602,18 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
} else { } else {
$langs->load("errors"); $langs->load("errors");
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")) . '">' . $langs->trans('CreateShipment') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . '</a></div>';
} }
} }
} }
// Reopen a closed order // Reopen a closed order
if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $user->rights->commande->creer) { if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=reopen">' . $langs->trans('ReOpen') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
} }
// Set to shipped // Set to shipped
if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $user->rights->commande->cloturer) { if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>';
} }
@ -2615,31 +2623,28 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>';
} }
if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>';
} }
} }
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>';
} }
} }
// Clone // Clone
if ($user->rights->commande->creer) { if ($usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>';
} }
// Cancel order // Cancel order
if ($object->statut == Commande::STATUS_VALIDATED && if ($object->statut == Commande::STATUS_VALIDATED && (! empty($usercanclose) || ! empty($usercancancel)))
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)))
)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';
} }
// Delete order // Delete order
if ($user->rights->commande->supprimer) { if ($usercandelete) {
if ($numshipping == 0) { if ($numshipping == 0) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>';
} else { } else {
@ -2662,18 +2667,18 @@ if ($action == 'create' && $user->rights->commande->creer)
// Documents // Documents
$comref = dol_sanitizeFileName($object->ref); $comref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf'; $relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->commande->dir_output . '/' . $comref; $filedir = $conf->commande->multidir_output[$object->entity] . '/' . $comref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->commande->lire; $genallowed = $usercanread;
$delallowed = $user->rights->commande->creer; $delallowed = $usercancreate;
print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object);
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$compatibleImportElementsList = false; $compatibleImportElementsList = false;
if($user->rights->commande->creer if($usercancreate
&& $object->statut == Commande::STATUS_DRAFT) && $object->statut == Commande::STATUS_DRAFT)
{ {
$compatibleImportElementsList = array('commande','propal'); // import from linked elements $compatibleImportElementsList = array('commande','propal'); // import from linked elements
@ -2710,7 +2715,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Presend form // Presend form
$modelmail='order_send'; $modelmail='order_send';
$defaulttopic='SendOrderRef'; $defaulttopic='SendOrderRef';
$diroutput = $conf->commande->dir_output; $diroutput = $conf->commande->multidir_output[$object->entity];
$trackid = 'ord'.$object->id; $trackid = 'ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -321,6 +321,7 @@ class Commande extends CommonOrder
public function valid($user, $idwarehouse = 0, $notrigger = 0) public function valid($user, $idwarehouse = 0, $notrigger = 0)
{ {
global $conf,$langs; global $conf,$langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0; $error=0;
@ -364,7 +365,7 @@ class Commande extends CommonOrder
// Validate // Validate
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET ref = '".$num."',"; $sql.= " SET ref = '".$this->db->escape($num)."',";
$sql.= " fk_statut = ".self::STATUS_VALIDATED.","; $sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
$sql.= " date_valid='".$this->db->idate($now)."',"; $sql.= " date_valid='".$this->db->idate($now)."',";
$sql.= " fk_user_valid = ".$user->id; $sql.= " fk_user_valid = ".$user->id;
@ -423,13 +424,18 @@ class Commande extends CommonOrder
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref) // Now we rename also files into index
// in order not to lose the attachments $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'commande/".$this->db->escape($this->newref)."'";
$sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->commande->dir_output.'/'.$oldref; $dirsource = $conf->commande->multidir_output[$this->entity].'/'.$oldref;
$dirdest = $conf->commande->dir_output.'/'.$newref; $dirdest = $conf->commande->multidir_output[$this->entity].'/'.$newref;
if (file_exists($dirsource)) if (! $error && file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
@ -437,7 +443,7 @@ class Commande extends CommonOrder
{ {
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref // Rename docs starting with $oldref with $newref
$listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); $listoffiles=dol_dir_list($conf->commande->multidir_output[$this->entity].'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach($listoffiles as $fileentry) foreach($listoffiles as $fileentry)
{ {
$dirsource=$fileentry['name']; $dirsource=$fileentry['name'];
@ -859,7 +865,7 @@ class Commande extends CommonOrder
$sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0); $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
$sql.= ", ".(int) $this->fk_incoterms; $sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".setEntity($this);
$sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
$sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null");
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
@ -1232,6 +1238,7 @@ class Commande extends CommonOrder
$this->lines[$i] = $line; $this->lines[$i] = $line;
} }
$this->entity = $object->entity;
$this->socid = $object->socid; $this->socid = $object->socid;
$this->fk_project = $object->fk_project; $this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id; $this->cond_reglement_id = $object->cond_reglement_id;
@ -1451,11 +1458,11 @@ class Commande extends CommonOrder
$pu_ht_devise = $tabprice[19]; $pu_ht_devise = $tabprice[19];
// Rang to use // Rang to use
$rangtouse = $rang; $ranktouse = $rang;
if ($rangtouse == -1) if ($ranktouse == -1)
{ {
$rangmax = $this->line_max($fk_parent_line); $rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1; $ranktouse = $rangmax + 1;
} }
// TODO A virer // TODO A virer
@ -1489,7 +1496,7 @@ class Commande extends CommonOrder
$this->line->fk_remise_except=$fk_remise_except; $this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent; $this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht; $this->line->subprice=$pu_ht;
$this->line->rang=$rangtouse; $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht; $this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva; $this->line->total_tva=$total_tva;
@ -3329,10 +3336,10 @@ class Commande extends CommonOrder
{ {
// Remove directory with files // Remove directory with files
$comref = dol_sanitizeFileName($this->ref); $comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->dir_output && !empty($this->ref)) if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref))
{ {
$dir = $conf->commande->dir_output . "/" . $comref ; $dir = $conf->commande->multidir_output[$this->entity] . "/" . $comref ;
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; $file = $conf->commande->multidir_output[$this->entity] . "/" . $comref . "/" . $comref . ".pdf";
if (file_exists($file)) // We must delete all files before deleting directory if (file_exists($file)) // We must delete all files before deleting directory
{ {
dol_delete_preview($this); dol_delete_preview($this);
@ -3405,6 +3412,7 @@ class Commande extends CommonOrder
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay=$conf->commande->client->warning_delay/60/60/24; $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
$response->label=$langs->trans("OrdersToProcess"); $response->label=$langs->trans("OrdersToProcess");
$response->labelShort = $langs->trans("Opened");
$response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders'; $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders';
$response->img=img_object('', "order"); $response->img=img_object('', "order");

View File

@ -72,7 +72,7 @@ $object = new Commande($db);
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
} }
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
@ -92,7 +92,7 @@ if ($id > 0 || ! empty($ref))
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->commande->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = commande_prepare_head($object); $head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order'); dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order');
@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref))
$modulepart = 'commande'; $modulepart = 'commande';
$permission = $user->rights->commande->creer; $permission = $user->rights->commande->creer;
$permtoedit = $user->rights->commande->creer; $permtoedit = $user->rights->commande->creer;
$param = '&id=' . $object->id; $param = '&id=' . $object->id.'&entity=' . (! empty($object->entity)?$object->entity:$conf->entity);
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
} }
else else

View File

@ -241,7 +241,7 @@ $max=5;
* Last modified orders * Last modified orders
*/ */
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,"; $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,";
$sql.= " s.nom as name, s.rowid as socid"; $sql.= " s.nom as name, s.rowid as socid";
$sql.= ", s.client"; $sql.= ", s.client";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
@ -297,7 +297,7 @@ if ($resql)
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';
@ -323,7 +323,7 @@ else dol_print_error($db);
*/ */
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
$sql.= ", s.client"; $sql.= ", s.client";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
$sql.= ", s.canvas"; $sql.= ", s.canvas";
@ -377,7 +377,7 @@ if (! empty($conf->commande->enabled))
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';
@ -405,7 +405,7 @@ if (! empty($conf->commande->enabled))
*/ */
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
$sql.= ", s.client"; $sql.= ", s.client";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
$sql.= ", s.canvas"; $sql.= ", s.canvas";
@ -459,7 +459,7 @@ if (! empty($conf->commande->enabled))
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -91,7 +91,7 @@ $id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int'));
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande', $id, ''); $result = restrictedArea($user, 'commande', $id, '');
$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; $diroutputmassaction=$conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id;
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
@ -143,6 +143,7 @@ $arrayfields=array(
'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
); );
@ -217,7 +218,7 @@ if (empty($reshook))
$objectlabel='Orders'; $objectlabel='Orders';
$permtoread = $user->rights->commande->lire; $permtoread = $user->rights->commande->lire;
$permtodelete = $user->rights->commande->supprimer; $permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output; $uploaddir = $conf->commande->multidir_output[$conf->entity];
$trigger_name='ORDER_SENTBYMAIL'; $trigger_name='ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
@ -247,7 +248,7 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,';
$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
$sql.= ' c.date_creation as date_creation, c.tms as date_update,'; $sql.= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label";
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields // Add fields from extrafields
@ -693,6 +694,12 @@ if ($resql)
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
// Date cloture
if (! empty($arrayfields['c.date_cloture']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status // Status
if (! empty($arrayfields['c.fk_statut']['checked'])) if (! empty($arrayfields['c.fk_statut']['checked']))
{ {
@ -748,7 +755,8 @@ if ($resql)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); if (! empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
print '</tr>'."\n"; print '</tr>'."\n";
@ -926,7 +934,7 @@ if ($resql)
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print '</td>'; print '</td>';
@ -1073,7 +1081,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook // Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation
@ -1092,6 +1100,14 @@ if ($resql)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Date cloture
if (! empty($arrayfields['c.date_cloture']['checked']))
{
print '<td align="center" class="nowrap">';
print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status // Status
if (! empty($arrayfields['c.fk_statut']['checked'])) if (! empty($arrayfields['c.fk_statut']['checked']))
{ {

View File

@ -548,7 +548,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
</script> </script>
<?php <?php
$sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.entity, c.ref, c.total_ht, c.ref_client,';
$sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$sql.= ', '.MAIN_DB_PREFIX.'commande as c'; $sql.= ', '.MAIN_DB_PREFIX.'commande as c';
@ -682,7 +682,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($objp->ref); $filename=dol_sanitizeFileName($objp->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); $filedir=$conf->commande->multidir_output[$objp->entity] . '/' . dol_sanitizeFileName($objp->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid;
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -236,8 +236,13 @@ if ($action == 'update')
$error++; $error++;
} }
// Fill array 'array_options' with data from add form $db->begin();
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if (! $error)
{
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
}
if (! $error) if (! $error)
{ {
@ -252,10 +257,20 @@ if ($action == 'update')
} }
else else
{ {
$error++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action='edit'; // Force chargement page edition $action='edit'; // Force chargement page edition
} }
} }
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
} }
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
@ -412,7 +427,7 @@ if ($action == 'create')
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
// Other attributes // Other attributes
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
@ -639,12 +654,12 @@ else
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>'; print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>'; print '<td>';
if ($object->fk_accountancy_journal > 0) { if ($object->fk_accountancy_journal > 0) {
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($object->fk_accountancy_journal); $accountingjournal->fetch($object->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0, 1, 1, '', 1); print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
} }
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -749,7 +749,6 @@ class Account extends CommonObject
$sql.= ",fk_pays = ".$this->country_id; $sql.= ",fk_pays = ".$this->country_id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1225,6 +1224,7 @@ class Account extends CommonObject
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
$response->label=$langs->trans("TransactionsToConciliate"); $response->label=$langs->trans("TransactionsToConciliate");
$response->labelShort = $langs->trans("TransactionsToConciliateShort");
$response->url=DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank'; $response->url=DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank';
$response->img=img_object('', "payment"); $response->img=img_object('', "payment");
@ -1276,7 +1276,6 @@ class Account extends CommonObject
$this->nb["banklines"]=$obj->nb; $this->nb["banklines"]=$obj->nb;
} }
$this->db->free($resql); $this->db->free($resql);
return 1;
} }
else else
{ {

View File

@ -23,6 +23,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
/** /**
* API class for accounts * API class for accounts
* *
* @property DoliDB db
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
*/ */
@ -166,6 +167,142 @@ class BankAccounts extends DolibarrApi
return $account->id; return $account->id;
} }
/**
* Create an internal wire transfer between two bank accounts
*
* @param int $bankaccount_from_id BankAccount ID to use as the source of the internal wire transfer {@from body}{@required true}
* @param int $bankaccount_to_id BankAccount ID to use as the destination of the internal wire transfer {@from body}{@required true}
* @param string $date Date of the internal wire transfer (UNIX timestamp) {@from body}{@required true}{@type timestamp}
* @param string $description Description of the internal wire transfer {@from body}{@required true}
* @param float $amount Amount to transfer from the source to the destination BankAccount {@from body}{@required true}
* @param float $amount_to Amount to transfer to the destination BankAccount (only when accounts does not share the same currency) {@from body}{@required false}
*
* @url POST /transfer
*
* @return array
*
* @status 201
*
* @throws 401 Unauthorized: User does not have permission to configure bank accounts
* @throws 404 Not Found: Either the source or the destination bankaccount for the provided id does not exist
* @throws 422 Unprocessable Entity: Refer to detailed exception message for the cause
* @throws 500 Internal Server Error: Error(s) returned by the RDBMS
*/
public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0)
{
if (! DolibarrApiAccess::$user->rights->banque->configurer) {
throw new RestException(401);
}
if ($bankaccount_from_id === $bankaccount_to_id) {
throw new RestException(422, 'bankaccount_from_id and bankaccount_to_id must be different !');
}
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$accountfrom = new Account($this->db);
$resultAccountFrom = $accountfrom->fetch($bankaccount_from_id);
if ($resultAccountFrom === 0) {
throw new RestException(404, 'The BankAccount for bankaccount_from_id provided does not exist.');
}
$accountto = new Account($this->db);
$resultAccountTo = $accountto->fetch($bankaccount_to_id);
if ($resultAccountTo === 0) {
throw new RestException(404, 'The BankAccount for bankaccount_to_id provided does not exist.');
}
if ($accountto->currency_code == $accountfrom->currency_code)
{
$amount_to = $amount;
}
else
{
if (!$amount_to || empty($amount_to))
{
throw new RestException(422, 'You must provide amount_to value since bankaccount_from and bankaccount_to does not share the same currency.');
}
}
$this->db->begin();
$error = 0;
$bank_line_id_from = 0;
$bank_line_id_to = 0;
$result = 0;
$user = DolibarrApiAccess::$user;
// By default, electronic transfert from bank to bank
$typefrom='PRE';
$typeto='VIR';
if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH)
{
// This is transfer of change
$typefrom='LIQ';
$typeto='LIQ';
}
/**
* Creating bank line records
*/
if (!$error) {
$bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1*price2num($amount), '', '', $user);
}
if (!($bank_line_id_from > 0)) {
$error++;
}
if (!$error) {
$bank_line_id_to = $accountto->addline($date, $typeto, $description, price2num($amount_to), '', '', $user);
}
if (!($bank_line_id_to > 0)) {
$error++;
}
/**
* Creating links between bank line record and its source
*/
$url = DOL_URL_ROOT.'/compta/bank/line.php?rowid=';
$label = '(banktransfert)';
$type = 'banktransfert';
if (!$error) {
$result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, $url, $label, $type);
}
if (!($result > 0)) {
$error++;
}
if (!$error) {
$result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, $url, $label, $type);
}
if (!($result > 0)) {
$error++;
}
if (!$error)
{
$this->db->commit();
return array(
'success' => array(
'code' => 201,
'message' => 'Internal wire transfer created successfully.'
)
);
}
else
{
$this->db->rollback();
throw new RestException(500, $accountfrom->error.' '.$accountto->error);
}
}
/** /**
* Update account * Update account
* *

View File

@ -0,0 +1 @@

View File

@ -267,9 +267,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$parameters = array('obj' => $obj); $parameters = array('obj' => $obj);
$reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook)){ if(empty($reshook)){
$ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref;
$refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp;
$paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : $paiement;
} }
$total_ttc = $obj->total_ttc; $total_ttc = $obj->total_ttc;
@ -312,7 +312,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook)){ if(empty($reshook)){
print $hookmanager->resPrint; print $hookmanager->resPrint;
$solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde;
} }
// solde // solde

View File

@ -544,16 +544,16 @@ if ($id)
{ {
if (! empty($user->rights->banque->modifier)) if (! empty($user->rights->banque->modifier))
{ {
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>';
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
} }
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
} }
print "</div>"; print "</div>";

View File

@ -88,7 +88,7 @@ if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcon
$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); $backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1);
$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record
if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH1))
{ {
setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors'); setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors');
} }
@ -132,16 +132,7 @@ elseif ($action=="add")
$error=0; $error=0;
foreach($arrayofpaymentmode as $key=>$val) foreach($arrayofpaymentmode as $key=>$val)
{ {
if (GETPOST($key.'_amount', 'alpha') == '') $object->$key = price2num(GETPOST($key.'_amount', 'alpha'));
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
$action='start';
$error++;
}
else
{
$object->$key = price2num(GETPOST($key.'_amount', 'alpha'));
}
} }
if (! $error) if (! $error)
@ -235,7 +226,14 @@ if ($action=="create" || $action=="start")
$posmodule = GETPOST('posmodule', 'alpha'); $posmodule = GETPOST('posmodule', 'alpha');
$terminalid = GETPOST('posnumber', 'alpha'); $terminalid = GETPOST('posnumber', 'alpha');
$terminaltouse = $terminalid; $terminaltouse = $terminalid;
if ($terminaltouse == '1') $terminaltouse = '';
if ($terminaltouse == '1' && $posmodule=='cashdesk') $terminaltouse = '';
if ($posmodule=='cashdesk' && $terminaltouse != '' && $terminaltouse != '1') {
$terminaltouse = '';
setEventMessages($langs->trans("OnlyTerminal1IsAvailableForCashDeskModule"), null, 'errors');
$error++;
}
// Calculate $initialbalanceforterminal for terminal 0 // Calculate $initialbalanceforterminal for terminal 0
foreach($arrayofpaymentmode as $key => $val) foreach($arrayofpaymentmode as $key => $val)
@ -247,7 +245,7 @@ if ($action=="create" || $action=="start")
} }
// Get the bank account dedicated to this point of sale module/terminal // Get the bank account dedicated to this point of sale module/terminal
$vartouse=CASHDESK_ID_BANKACCOUNT_CASH.$terminaltouse; $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse;
$bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal)
// Hook to get the good bank id according to posmodule and posnumber. // Hook to get the good bank id according to posmodule and posnumber.
// @TODO add hook here // @TODO add hook here
@ -271,7 +269,7 @@ if ($action=="create" || $action=="start")
} }
else else
{ {
setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminalid), null, 'errors'); setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors');
$error++; $error++;
} }
} }

View File

@ -196,10 +196,18 @@ if ($resql)
// Bank account // Bank account
print '<td class="nowrap right">'; print '<td class="nowrap right">';
print $bankaccount->getNomUrl(1); print $bankaccount->getNomUrl(1);
if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount; if ($cashcontrol->posmodule=="takepos"){
elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount; if ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber}==$bankaccount->id) $cash+=$objp->amount;
elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount; elseif ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$cashcontrol->posnumber}==$bankaccount->id) $bank+=$objp->amount;
else $other+=$objp->amount; elseif ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$cashcontrol->posnumber}==$bankaccount->id) $cheque+=$objp->amount;
else $other+=$objp->amount;
}
else{
if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount;
elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount;
elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount;
else $other+=$objp->amount;
}
print "</td>\n"; print "</td>\n";
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;

View File

@ -190,7 +190,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print $socialcontrib->getNomUrl(1, '20'); print $socialcontrib->getNomUrl(1, '20');
print '</td>'; print '</td>';
// Type // Type
print '<td><a href="../sociales/index.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>'; print '<td><a href="../sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
// Expected to pay // Expected to pay
print '<td class="right">'.price($obj->total).'</td>'; print '<td class="right">'.price($obj->total).'</td>';
// Ref payment // Ref payment

View File

@ -309,6 +309,38 @@ if (empty($reshook))
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->retained_warranty_fk_cond_reglement = 0; // To clean property
$result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int'));
if ($result < 0) dol_print_error($db, $object->error);
$old_rw_date_lim_reglement = $object->retained_warranty_date_limit;
$new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement);
if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement;
if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
}
elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float'));
if ($result < 0)
dol_print_error($db, $object->error);
}
elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float'));
if ($result < 0)
dol_print_error($db, $object->error);
}
// Multicurrency Code // Multicurrency Code
elseif ($action == 'setmulticurrencycode' && $usercancreate) { elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
@ -913,7 +945,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Proprietes particulieres a facture de remplacement // Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement']; $object->fk_facture_source = $_POST['fac_replacement'];
@ -947,7 +978,7 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
if(!empty($originentity)){ if (!empty($originentity)) {
$object->entity = $originentity; $object->entity = $originentity;
} }
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
@ -969,7 +1000,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Proprietes particulieres a facture avoir // Proprietes particulieres a facture avoir
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
@ -1151,7 +1181,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Source facture // Source facture
$object->fac_rec = GETPOST('fac_rec', 'int'); $object->fac_rec = GETPOST('fac_rec', 'int');
@ -1202,13 +1231,22 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
if (GETPOST('type') == Facture::TYPE_SITUATION) if (GETPOST('type') == Facture::TYPE_SITUATION)
{ {
$object->situation_counter = 1; $object->situation_counter = 1;
$object->situation_final = 0; $object->situation_final = 0;
$object->situation_cycle_ref = $object->newCycle(); $object->situation_cycle_ref = $object->newCycle();
$object->retained_warranty = GETPOST('retained_warranty', 'int');
$object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
$retained_warranty_date_limit = GETPOST('retained_warranty_date_limit');
if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){
$object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit);
}
$object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement);
} }
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -2449,7 +2487,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Actions to build doc // Actions to build doc
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->multidir_output[$object->entity];
$permissioncreate=$usercancreate; $permissioncreate=$usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
@ -3147,6 +3185,44 @@ if ($action == 'create')
$form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
if (! empty($conf->global->INVOICE_USE_SITUATION))
{
if($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY){
$rwStyle = 'display:none;';
if(GETPOST('type', 'int') == Facture::TYPE_SITUATION){
$rwStyle = '';
}
$retained_warranty = GETPOST('retained_warranty', 'int');
$retained_warranty = !empty($retained_warranty)?$retained_warranty:$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT;
print '<tr class="retained-warranty-line" style="'.$rwStyle.'" ><td class="nowrap">' . $langs->trans('RetainedWarranty') . '</td><td colspan="2">';
print '<input id="new-situation-invoice-retained-warranty" name="retained_warranty" type="number" value="'.$retained_warranty.'" step="0.01" min="0" max="100" />%';
// Retained warranty payment term
print '<tr class="retained-warranty-line" style="'.$rwStyle.'" ><td class="nowrap">' . $langs->trans('PaymentConditionsShortRetainedWarranty') . '</td><td colspan="2">';
$retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
$form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1);
print '</td></tr>';
print '<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("[name=\'type\'").change(function() {
if($( this ).prop("checked") && $( this ).val() == '.Facture::TYPE_SITUATION.')
{
$(".retained-warranty-line").show();
}
else{
$(".retained-warranty-line").hide();
}
});
});
</script>';
}
}
// Payment mode // Payment mode
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">'; print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
$form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT'); $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT');
@ -3236,8 +3312,8 @@ if ($action == 'create')
'__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')', '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')',
'__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')', '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')',
'__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')', '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')',
'__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')', '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')',
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')', '__INVOICE_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')' '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'
); );
@ -4020,6 +4096,126 @@ elseif ($id > 0 || ! empty($ref))
print '</td></tr>'; print '</td></tr>';
} }
$displayWarranty = false;
if( ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) )
{
// Check if this situation invoice is 100% for real
if(!empty($object->situation_final) && !empty($object->lines)){
$displayWarranty = true;
foreach($object->lines as $i => $line){
if($line->product_type < 2 && $line->situation_percent < 100){
$displayWarranty = false;
break;
}
}
}
// Retained Warranty
print '<tr class="retained-warranty-lines" ><td>';
print '<table id="retained-warranty-table" class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RetainedWarranty');
print '</td>';
if ($action != 'editretainedwarranty' && $user->rights->facture->creer){
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editretainedwarranty&amp;facid=' . $object->id . '">' . img_edit($langs->trans('setretainedwarranty'), 1) . '</a></td>';
}
print '</tr></table>';
print '</td><td>';
if ($action == 'editretainedwarranty')
{
print '<form id="retained-warranty-form" method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarranty">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input name="retained_warranty" type="number" step="0.01" min="0" max="100" value="'.$object->retained_warranty.'" >';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';
}
else
{
print price($object->retained_warranty).'%';
}
print '</td></tr>';
// Retained warranty payment term
print '<tr class="retained-warranty-lines" ><td>';
print '<table id="retained-warranty-cond-reglement-table" class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShortRetainedWarranty');
print '</td>';
if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer){
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editretainedwarrantypaymentterms&amp;facid=' . $object->id . '">' . img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1) . '</a></td>';
}
print '</tr></table>';
print '</td><td>';
$defaultDate = !empty($object->retained_warranty_date_limit)?$object->retained_warranty_date_limit:strtotime('-1 years', $object->date_lim_reglement);
if($object->date > $defaultDate){
$defaultDate = $object->date;
}
if ($action == 'editretainedwarrantypaymentterms')
{
//date('Y-m-d',$object->date_lim_reglement)
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarrantyconditions">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement;
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
$form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1);
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';
}
else
{
print $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->retained_warranty_fk_cond_reglement, 'none');
if(!$displayWarranty){
print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" ');
}
}
print '</td></tr>';
if($displayWarranty)
{
// Retained Warranty payment date limit
print '<tr class="retained-warranty-lines" ><td>';
print '<table id="retained-warranty-date-limit-table" class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RetainedWarrantyDateLimit');
print '</td>';
if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer){
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editretainedwarrantydatelimit&amp;facid=' . $object->id . '">' . img_edit($langs->trans('setretainedwarrantyDateLimit'), 1) . '</a></td>';
}
print '</tr></table>';
print '</td><td>';
$defaultDate = !empty($object->retained_warranty_date_limit)?$object->retained_warranty_date_limit:strtotime('-1 years', $object->date_lim_reglement);
if($object->date > $defaultDate){
$defaultDate = $object->date;
}
if ($action == 'editretainedwarrantydatelimit')
{
//date('Y-m-d',$object->date_lim_reglement)
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarrantydatelimit">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input name="retained_warranty_date_limit" type="date" step="1" min="'.dol_print_date($object->date, '%Y-%m-%d').'" value="'.dol_print_date($defaultDate, '%Y-%m-%d').'" >';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';
}
else
{
print dol_print_date($object->retained_warranty_date_limit, 'day');
}
print '</td></tr>';
}
}
// Other attributes // Other attributes
$cols = 2; $cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
@ -4464,6 +4660,31 @@ elseif ($id > 0 || ! empty($ref))
print ' :</td>'; print ' :</td>';
print '<td class="right'.($resteapayeraffiche?' amountremaintopay':(' '.$cssforamountpaymentcomplete)).'">' . price($resteapayeraffiche) . '</td>'; print '<td class="right'.($resteapayeraffiche?' amountremaintopay':(' '.$cssforamountpaymentcomplete)).'">' . price($resteapayeraffiche) . '</td>';
print '<td class="nowrap">&nbsp;</td></tr>'; print '<td class="nowrap">&nbsp;</td></tr>';
// Retained warranty : usualy use on construction industry
if(!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty){
// Billed - retained warranty
if($object->type == Facture::TYPE_SITUATION)
{
$retainedWarranty = $total_global_ttc * $object->retained_warranty / 100;
}
else
{
// Because one day retained warranty could be used on standard invoices
$retainedWarranty = $object->total_ttc * $object->retained_warranty / 100;
}
$billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ;
print '<tr><td colspan="' . $nbcols . '" align="right">' . $langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')) . ' :</td><td align="right">' . price($billedWithRetainedWarranty) . '</td><td>&nbsp;</td></tr>';
// retained warranty
print '<tr><td colspan="' . $nbcols . '" align="right">';
print $langs->trans("RetainedWarranty") . ' ('.$object->retained_warranty.'%)';
print !empty($object->retained_warranty_date_limit)?' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):'';
print ' :</td><td align="right">' . price($retainedWarranty) . '</td><td>&nbsp;</td></tr>';
}
} }
else // Credit note else // Credit note
{ {
@ -4911,12 +5132,12 @@ elseif ($id > 0 || ! empty($ref))
// Documents generes // Documents generes
$filename = dol_sanitizeFileName($object->ref); $filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); $filedir = $conf->facture->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
$genallowed = $usercanread; $genallowed = $usercanread;
$delallowed = $usercancreate; $delallowed = $usercancreate;
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object);
$somethingshown = $formfile->numoffiles; $somethingshown = $formfile->numoffiles;
// Show links to link elements // Show links to link elements
@ -4963,7 +5184,7 @@ elseif ($id > 0 || ! empty($ref))
// Presend form // Presend form
$modelmail='facture_send'; $modelmail='facture_send';
$defaulttopic='SendBillRef'; $defaulttopic='SendBillRef';
$diroutput = $conf->facture->dir_output; $diroutput = $conf->facture->multidir_output[$object->entity];
$trackid = 'inv'.$object->id; $trackid = 'inv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -206,6 +206,21 @@ class Facture extends CommonInvoice
public $oldcopy; public $oldcopy;
/**
* @var double percentage of retainage
*/
public $retained_warranty;
/**
* @var int timestamp of date limit of retainage
*/
public $retained_warranty_date_limit;
/**
* @var int Code in llx_c_paiement
*/
public $retained_warranty_fk_cond_reglement;
/** /**
* Standard invoice * Standard invoice
*/ */
@ -303,7 +318,6 @@ class Facture extends CommonInvoice
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
$this->brouillon = 1; $this->brouillon = 1;
if (empty($this->entity)) $this->entity = $conf->entity;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) // 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); if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
@ -472,10 +486,13 @@ class Facture extends CommonInvoice
$sql.= ", fk_multicurrency"; $sql.= ", fk_multicurrency";
$sql.= ", multicurrency_code"; $sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx"; $sql.= ", multicurrency_tx";
$sql.= ", retained_warranty";
$sql.= ", retained_warranty_date_limit";
$sql.= ", retained_warranty_fk_cond_reglement";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$this->entity; $sql.= ", ".setEntity($this);
$sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
$sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$this->db->escape($this->type)."'";
$sql.= ", '".$socid."'"; $sql.= ", '".$socid."'";
@ -506,6 +523,10 @@ class Facture extends CommonInvoice
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx; $sql.= ", ".(double) $this->multicurrency_tx;
$sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty));
$sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL');
$sql.= ", ".(int) $this->retained_warranty_fk_cond_reglement;
$sql.=")"; $sql.=")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -914,8 +935,8 @@ class Facture extends CommonInvoice
$facture->remise_absolue = $this->remise_absolue; $facture->remise_absolue = $this->remise_absolue;
$facture->remise_percent = $this->remise_percent; $facture->remise_percent = $this->remise_percent;
$facture->origin = $this->origin; $facture->origin = $this->origin;
$facture->origin_id = $this->origin_id; $facture->origin_id = $this->origin_id;
$facture->lines = $this->lines; // Array of lines of invoice $facture->lines = $this->lines; // Array of lines of invoice
$facture->products = $this->lines; // Tant que products encore utilise $facture->products = $this->lines; // Tant que products encore utilise
@ -1336,6 +1357,7 @@ class Facture extends CommonInvoice
$sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ', f.fk_incoterms, f.location_incoterms';
$sql.= ', f.module_source, f.pos_source'; $sql.= ', f.module_source, f.pos_source';
$sql.= ", i.libelle as label_incoterms"; $sql.= ", i.libelle as label_incoterms";
$sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$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_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_paiement as p ON f.fk_mode_reglement = p.id';
@ -1405,6 +1427,10 @@ class Facture extends CommonInvoice
$this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_cycle_ref = $obj->situation_cycle_ref;
$this->situation_counter = $obj->situation_counter; $this->situation_counter = $obj->situation_counter;
$this->situation_final = $obj->situation_final; $this->situation_final = $obj->situation_final;
$this->retained_warranty = $obj->retained_warranty;
$this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit);
$this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement;
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);
//Incoterms //Incoterms
@ -1597,7 +1623,11 @@ class Facture extends CommonInvoice
$this->tab_previous_situation_invoice = array(); $this->tab_previous_situation_invoice = array();
$this->tab_next_situation_invoice = array(); $this->tab_next_situation_invoice = array();
$sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC'; $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture';
$sql.= ' WHERE rowid <> '.$this->id;
$sql.= ' AND entity = '.$this->entity;
$sql.= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref;
$sql.= ' ORDER BY situation_counter ASC';
dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1648,6 +1678,8 @@ class Facture extends CommonInvoice
if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key=trim($this->import_key); if (isset($this->import_key)) $this->import_key=trim($this->import_key);
if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
@ -1688,7 +1720,10 @@ class Facture extends CommonInvoice
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").",";
$sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).",";
$sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).",";
$sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)); $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)).",";
$sql.= " retained_warranty=".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)).",";
$sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').",";
$sql.= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement)?intval($this->retained_warranty_fk_cond_reglement):"null");
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
$this->db->begin(); $this->db->begin();
@ -2429,13 +2464,18 @@ class Facture extends CommonInvoice
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// Rename of object directory ($this->ref = old ref, $num = new ref) // Now we rename also files into index
// to not lose the linked files $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->db->escape($this->newref)."'";
$sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->facture->dir_output.'/'.$oldref; $dirsource = $conf->facture->dir_output.'/'.$oldref;
$dirdest = $conf->facture->dir_output.'/'.$newref; $dirdest = $conf->facture->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (! $error && file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
@ -2788,11 +2828,11 @@ class Facture extends CommonInvoice
$pu_ht_devise = $tabprice[19]; $pu_ht_devise = $tabprice[19];
// Rank to use // Rank to use
$rangtouse = $rang; $ranktouse = $rang;
if ($rangtouse == -1) if ($ranktouse == -1)
{ {
$rangmax = $this->line_max($fk_parent_line); $rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1; $ranktouse = $rangmax + 1;
} }
// Insert line // Insert line
@ -2826,7 +2866,7 @@ class Facture extends CommonInvoice
$this->line->date_start=$date_start; $this->line->date_start=$date_start;
$this->line->date_end=$date_end; $this->line->date_end=$date_end;
$this->line->ventil=$ventil; $this->line->ventil=$ventil;
$this->line->rang=$rangtouse; $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->fk_remise_except=$fk_remise_except; $this->line->fk_remise_except=$fk_remise_except;
@ -3458,7 +3498,7 @@ class Facture extends CommonInvoice
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice"));
return ""; return "";
} }
} }
@ -3663,11 +3703,11 @@ class Facture extends CommonInvoice
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
$sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir
if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ if (! empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) {
// Select the last situation invoice // Select the last situation invoice
$sqlSit = 'SELECT MAX(fs.rowid)'; $sqlSit = 'SELECT MAX(fs.rowid)';
$sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs";
$sqlSit.= " WHERE fs.entity = ".$conf->entity; $sqlSit.= " WHERE fs.entity IN (".getEntity('invoice').")";
$sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION;
$sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")";
$sqlSit.= " GROUP BY fs.situation_cycle_ref"; $sqlSit.= " GROUP BY fs.situation_cycle_ref";
@ -3884,6 +3924,7 @@ class Facture extends CommonInvoice
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay=$conf->facture->client->warning_delay/60/60/24; $response->warning_delay=$conf->facture->client->warning_delay/60/60/24;
$response->label=$langs->trans("CustomerBillsUnpaid"); $response->label=$langs->trans("CustomerBillsUnpaid");
$response->labelShort=$langs->trans("Unpaid");
$response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&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"); $response->img=img_object('', "bill");
@ -4193,7 +4234,7 @@ class Facture extends CommonInvoice
public function newCycle() public function newCycle()
{ {
$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f';
$sql.= " WHERE f.entity in (".getEntity('invoice', 0).")"; $sql.= " WHERE f.entity IN (".getEntity('invoice', 0).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($resql->num_rows > 0) if ($resql->num_rows > 0)
@ -4237,8 +4278,8 @@ class Facture extends CommonInvoice
global $conf; global $conf;
$sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture';
$sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; $sql .= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$sql .= ' and situation_counter < ' . $this->situation_counter; $sql .= ' AND situation_counter < ' . $this->situation_counter;
$sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
$res = array(); $res = array();
@ -4319,7 +4360,9 @@ class Facture extends CommonInvoice
if (!empty($this->situation_cycle_ref)) { if (!empty($this->situation_cycle_ref)) {
// No point in testing anything if we're not inside a cycle // No point in testing anything if we're not inside a cycle
$sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture';
$sql.= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$sql.= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) { if ($resql && $resql->num_rows > 0) {
@ -4369,6 +4412,137 @@ class Facture extends CommonInvoice
return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
} }
/**
* @return number or -1 if not available
*/
public function getRetainedWarrantyAmount()
{
if(empty($this->retained_warranty) ){
return -1;
}
$retainedWarrantyAmount = 0;
// Billed - retained warranty
if($this->type == Facture::TYPE_SITUATION)
{
$displayWarranty = true;
// Check if this situation invoice is 100% for real
if(!empty($this->lines)){
foreach($this->lines as $i => $line){
if($line->product_type < 2 && $line->situation_percent < 100){
$displayWarranty = false;
break;
}
}
}
if($displayWarranty && !empty($this->situation_final))
{
$this->fetchPreviousNextSituationInvoice();
$TPreviousIncoice = $this->tab_previous_situation_invoice;
$total2BillWT = 0;
foreach ($TPreviousIncoice as &$fac){
$total2BillWT += $fac->total_ttc;
}
$total2BillWT += $this->total_ttc;
$retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100;
}
else{
return -1;
}
}
else
{
// Because one day retained warranty could be used on standard invoices
$retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
}
return $retainedWarrantyAmount;
}
/**
* Change the retained warranty
*
* @param float $value value of retained warranty
* @return int >0 if OK, <0 if KO
*/
public function setRetainedWarranty($value)
{
dol_syslog(get_class($this).'::setRetainedWarranty('.$value.')');
if ($this->statut >= 0)
{
$fieldname = 'retained_warranty';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.floatval($value);
$sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql))
{
$this->retained_warranty = floatval($value);
return 1;
}
else
{
dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
}
/**
* Change the retained_warranty_date_limit
*
* @param int $timestamp date limit of retained warranty in timestamp format
* @param string $dateYmd date limit of retained warranty in Y m d format
* @return int >0 if OK, <0 if KO
*/
public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false)
{
if(!$timestamp && $dateYmd){
$timestamp = $this->db->jdate($dateYmd);
}
dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')');
if ($this->statut >= 0)
{
$fieldname = 'retained_warranty_date_limit';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' );
$sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql))
{
$this->retained_warranty_date_limit = $timestamp;
return 1;
}
else
{
dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
}
} }
/** /**

View File

@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref))
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = facture_prepare_head($object); $head = facture_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill');

View File

@ -1017,8 +1017,8 @@ if ($action == 'create')
$substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B').')'; $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B').')';
$substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')'; $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')';
$substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')';
$substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')';
$substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')';
$substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')';
// Only on template invoices // Only on template invoices
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')';
@ -1359,8 +1359,8 @@ else
$substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')'; $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')';
$substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')'; $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')';
$substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')';
$substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')';
$substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')';
$substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')';
// Only on template invoices // Only on template invoices
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')';

View File

@ -182,6 +182,12 @@ $arrayfields=array(
'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
); );
if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
{
$arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0);
}
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
@ -373,6 +379,10 @@ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
$sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
$sql.= ' f.paye as paye, f.fk_statut,'; $sql.= ' f.paye as paye, f.fk_statut,';
$sql.= ' f.datec as date_creation, f.tms as date_update,'; $sql.= ' f.datec as date_creation, f.tms as date_update,';
if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
{
$sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,';
}
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
$sql.= " typent.code as typent_code,"; $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
@ -605,7 +615,7 @@ if ($resql)
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$newcardbutton=''; $newcardbutton='';
if($user->rights->facture->creer) if($user->rights->facture->creer && $contextpage != 'poslist')
{ {
$newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create');
} }
@ -687,7 +697,7 @@ if ($resql)
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -834,6 +844,13 @@ if ($resql)
print '<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; print '<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>'; print '</td>';
} }
if(! empty($arrayfields['f.retained_warranty']['checked']))
{
print '<td class="liste_titre" align="right">';
print '</td>';
}
if (! empty($arrayfields['dynamount_payed']['checked'])) if (! empty($arrayfields['dynamount_payed']['checked']))
{ {
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
@ -899,6 +916,7 @@ if ($resql)
if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder);
if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
// Extra fields // Extra fields
@ -939,7 +957,15 @@ if ($resql)
$facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
$facturestatic->note_public=$obj->note_public; $facturestatic->note_public=$obj->note_public;
$facturestatic->note_private=$obj->note_private; $facturestatic->note_private=$obj->note_private;
if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
{
$facturestatic->retained_warranty=$obj->retained_warranty;
$facturestatic->retained_warranty_date_limit=$obj->retained_warranty_date_limit;
$facturestatic->situation_final=$obj->retained_warranty_date_limit;
$facturestatic->situation_final=$obj->retained_warranty_date_limit;
$facturestatic->situation_cycle_ref=$obj->situation_cycle_ref;
$facturestatic->situation_counter=$obj->situation_counter;
}
$thirdpartystatic->id=$obj->socid; $thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name; $thirdpartystatic->name=$obj->name;
$thirdpartystatic->client=$obj->client; $thirdpartystatic->client=$obj->client;
@ -1068,7 +1094,14 @@ if ($resql)
if (! empty($arrayfields['s.nom']['checked'])) if (! empty($arrayfields['s.nom']['checked']))
{ {
print '<td class="tdoverflowmax200">'; print '<td class="tdoverflowmax200">';
print $thirdpartystatic->getNomUrl(1, 'customer'); if ($contextpage == 'poslist')
{
print $thirdpartystatic->name;
}
else
{
print $thirdpartystatic->getNomUrl(1, 'customer');
}
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -1181,6 +1214,11 @@ if ($resql)
$totalarray['totalttc'] += $obj->total_ttc; $totalarray['totalttc'] += $obj->total_ttc;
} }
if(! empty($arrayfields['f.retained_warranty']['checked']))
{
print '<td align="right">'.(! empty($obj->retained_warranty)?price($obj->retained_warranty).'%':'&nbsp;').'</td>';
}
if (! empty($arrayfields['dynamount_payed']['checked'])) if (! empty($arrayfields['dynamount_payed']['checked']))
{ {
print '<td class="right nowrap">'.(! empty($totalpay)?price($totalpay, 0, $langs):'&nbsp;').'</td>'; // TODO Use a denormalized field print '<td class="right nowrap">'.(! empty($totalpay)?price($totalpay, 0, $langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
@ -1200,7 +1238,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook // Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation
@ -1230,7 +1268,7 @@ if ($resql)
// Action column // Action column
print '<td class="nowrap" align="center">'; print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{ {
$selected=0; $selected=0;
if (in_array($obj->id, $arrayofselected)) $selected=1; if (in_array($obj->id, $arrayofselected)) $selected=1;

View File

@ -539,7 +539,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,';
$sql.= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; $sql.= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' WHERE f.entity IN ('.getEntity('invoice', $conf->entity).')'; $sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
$sql.= ' AND (f.fk_soc = '.$facture->socid; $sql.= ' AND (f.fk_soc = '.$facture->socid;
// Can pay invoices of all child of parent company // Can pay invoices of all child of parent company
if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
@ -597,7 +597,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<td class="right">'.$alreadypayedlabel.'</td>'; print '<td class="right">'.$alreadypayedlabel.'</td>';
print '<td class="right">'.$remaindertopay.'</td>'; print '<td class="right">'.$remaindertopay.'</td>';
print '<td class="right">'.$langs->trans('PaymentAmount').'</td>'; print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
print '<td class="right">&nbsp;</td>';
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
print '<td align="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$total=0; $total=0;
@ -744,6 +748,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
} }
print "</td>"; print "</td>";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
// Warning // Warning
print '<td align="center" width="16">'; print '<td align="center" width="16">';
//print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>"; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
@ -754,9 +761,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
} }
print '</td>'; print '</td>';
$parameters=array();
$reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
print "</tr>\n"; print "</tr>\n";
$total+=$objp->total; $total+=$objp->total;
@ -893,12 +897,13 @@ if (! GETPOST('action', 'aZ09'))
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n"; print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n"; print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n"; print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
print '<td class="right">'.price($objp->amount).'</td><td>&nbsp;</td>'; print '<td class="right">'.price($objp->amount).'</td>';
print '<td>&nbsp;</td>';
$parameters=array();
$reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
print '</tr>'; print '</tr>';
$parameters=array();
$reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
$i++; $i++;
} }
print '</table>'; print '</table>';

View File

@ -489,7 +489,7 @@ class RemiseCheque extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Bank"));
return ""; return "";
} }
} }
@ -527,6 +527,7 @@ class RemiseCheque extends CommonObject
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24; $response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24;
$response->label=$langs->trans("BankChecksToReceipt"); $response->label=$langs->trans("BankChecksToReceipt");
$response->labelShort=$langs->trans("BankChecksToReceiptShort");
$response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank'; $response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank';
$response->img=img_object('', "payment"); $response->img=img_object('', "payment");

View File

@ -1141,7 +1141,7 @@ class Paiement extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice"));
return ""; return "";
} }
} }

View File

@ -1417,7 +1417,7 @@ class BonPrelevement extends CommonObject
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; $sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum"; $sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql.= " FROM"; $sql.= " FROM";
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql.= " ".MAIN_DB_PREFIX."facture as f,"; $sql.= " ".MAIN_DB_PREFIX."facture as f,";
@ -1443,7 +1443,8 @@ class BonPrelevement extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum, $obj->rum); $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
$this->total = $this->total + $obj->somme; $this->total = $this->total + $obj->somme;
$i++; $i++;
} }

View File

@ -78,7 +78,7 @@ if (empty($reshook))
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
$bprev = new BonPrelevement($db); $bprev = new BonPrelevement($db);
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear')); $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear'));
$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate); $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate);
if ($result < 0) if ($result < 0)
{ {
@ -116,7 +116,7 @@ llxHeader('', $langs->trans("NewStandingOrder"));
if (prelevement_check_config() < 0) if (prelevement_check_config() < 0)
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
} }
/*$h=0; /*$h=0;

View File

@ -58,7 +58,7 @@ llxHeader('', $langs->trans("CustomersStandingOrdersArea"));
if (prelevement_check_config() < 0) if (prelevement_check_config() < 0)
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
} }
print load_fiche_titre($langs->trans("CustomersStandingOrdersArea")); print load_fiche_titre($langs->trans("CustomersStandingOrdersArea"));

View File

@ -130,21 +130,6 @@ $AccCat = new AccountancyCategory($db);
* View * View
*/ */
$months = array(
$langs->trans("JanuaryMin"),
$langs->trans("FebruaryMin"),
$langs->trans("MarchMin"),
$langs->trans("AprilMin"),
$langs->trans("MayMin"),
$langs->trans("JuneMin"),
$langs->trans("JulyMin"),
$langs->trans("AugustMin"),
$langs->trans("SeptemberMin"),
$langs->trans("OctoberMin"),
$langs->trans("NovemberMin"),
$langs->trans("DecemberMin"),
);
llxHeader(); llxHeader();
$form=new Form($db); $form=new Form($db);

View File

@ -143,18 +143,18 @@ $AccCat = new AccountancyCategory($db);
*/ */
$months = array( $months = array(
$langs->trans("JanuaryMin"), $langs->trans("MonthShort01"),
$langs->trans("FebruaryMin"), $langs->trans("MonthShort02"),
$langs->trans("MarchMin"), $langs->trans("MonthShort03"),
$langs->trans("AprilMin"), $langs->trans("MonthShort04"),
$langs->trans("MayMin"), $langs->trans("MonthShort05"),
$langs->trans("JuneMin"), $langs->trans("MonthShort06"),
$langs->trans("JulyMin"), $langs->trans("MonthShort07"),
$langs->trans("AugustMin"), $langs->trans("MonthShort08"),
$langs->trans("SeptemberMin"), $langs->trans("MonthShort09"),
$langs->trans("OctoberMin"), $langs->trans("MonthShort10"),
$langs->trans("NovemberMin"), $langs->trans("MonthShort11"),
$langs->trans("DecemberMin"), $langs->trans("MonthShort12"),
); );
llxheader('', $langs->trans('ReportInOut')); llxheader('', $langs->trans('ReportInOut'));

View File

@ -710,37 +710,37 @@ if ($id > 0)
// Reopen // Reopen
if ($object->paye && $user->rights->tax->charges->creer) if ($object->paye && $user->rights->tax->charges->creer)
{ {
print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php", 1). "?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a>"; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php", 1). "?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a></div>";
} }
// Edit // Edit
if ($object->paye == 0 && $user->rights->tax->charges->creer) if ($object->paye == 0 && $user->rights->tax->charges->creer)
{ {
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a>"; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a></div>";
} }
// Emit payment // Emit payment
if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer) if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer)
{ {
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_charge.php?id=$object->id&amp;action=create\">".$langs->trans("DoPayment")."</a>"; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_charge.php?id=$object->id&amp;action=create\">".$langs->trans("DoPayment")."</a></div>";
} }
// Classify 'paid' // Classify 'paid'
if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer) if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer)
{ {
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a>"; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a></div>";
} }
// Clone // Clone
if ($user->rights->tax->charges->creer) if ($user->rights->tax->charges->creer)
{ {
print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php", 1). "?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a>"; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php", 1). "?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a></div>";
} }
// Delete // Delete
if ($user->rights->tax->charges->supprimer) if ($user->rights->tax->charges->supprimer)
{ {
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=delete\">".$langs->trans("Delete")."</a>"; print "<div class=\"inline-block divButAction\"><a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=delete\">".$langs->trans("Delete")."</a></div>";
} }
print "</div>"; print "</div>";

View File

@ -317,7 +317,7 @@ class ChargeSociales extends CommonObject
$sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'";
$sql.= ", periode='".$this->db->idate($this->periode)."'"; $sql.= ", periode='".$this->db->idate($this->periode)."'";
$sql.= ", amount='".price2num($this->amount, 'MT')."'"; $sql.= ", amount='".price2num($this->amount, 'MT')."'";
$sql.= ", fk_projet='".$this->db->escape($this->fk_project)."'"; $sql.= ", fk_projet=".($this->fk_project>0?$this->db->escape($this->fk_project):"NULL");
$sql.= ", fk_user_modif=".$user->id; $sql.= ", fk_user_modif=".$user->id;
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;

View File

@ -187,7 +187,7 @@ if ($resql)
if ($year) if ($year)
{ {
$center=($year?"<a href='index.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1)."'>".img_next()."</a>":""); $center=($year?"<a href='list.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='list.php?year=".($year+1)."'>".img_next()."</a>":"");
print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
} }
else else
@ -281,7 +281,7 @@ if ($resql)
print '<td align="center">'; print '<td align="center">';
if ($obj->periode) if ($obj->periode)
{ {
print '<a href="index.php?year='.strftime("%Y", $db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').'</a>'; print '<a href="list.php?year='.strftime("%Y", $db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').'</a>';
} }
else else
{ {

View File

@ -90,7 +90,7 @@ print '<input type="hidden" name="mode" value="'.$mode.'">';
if ($mode != 'sconly') if ($mode != 'sconly')
{ {
$center=($year?'<a href="index.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="index.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":""); $center=($year?'<a href="list.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="list.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1);
} }
else else
@ -181,7 +181,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print $socialcontrib->getNomUrl(1, '20'); print $socialcontrib->getNomUrl(1, '20');
print '</td>'; print '</td>';
// Type // Type
print '<td><a href="../sociales/index.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>'; print '<td><a href="../sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
// Date // Date
$date=$obj->periode; $date=$obj->periode;
if (empty($date)) $date=$obj->date_ech; if (empty($date)) $date=$obj->date_ech;

View File

@ -385,16 +385,16 @@ if ($id)
{ {
if (! empty($user->rights->tax->charges->supprimer)) if (! empty($user->rights->tax->charges->supprimer))
{ {
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>';
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
} }
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
} }
print "</div>"; print "</div>";
} }

View File

@ -1217,11 +1217,12 @@ class Contact extends CommonObject
public function getCivilityLabel() public function getCivilityLabel()
{ {
global $langs; global $langs;
$langs->load("dict");
$code=(! empty($this->civility_id)?$this->civility:(! empty($this->civilite)?$this->civilite:'')); $code=($this->civility_code ? $this->civility_code : (! empty($this->civility_id)?$this->civility:(! empty($this->civilite)?$this->civilite:'')));
if (empty($code)) return ''; if (empty($code)) return '';
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
$langs->load("dict");
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
} }
/** /**

View File

@ -38,7 +38,7 @@ $id = GETPOST('id', 'int');
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$object = new Contact($db); $object = new Contact($db);
if ($id > 0) $object->fetch($id); if ($id > 0) $object->fetch($id);
if(empty($object->thirdparty)) $object->fetch_thirdparty(); if (empty($object->thirdparty)) $object->fetch_thirdparty();
$socid = $object->thirdparty->id; $socid = $object->thirdparty->id;
// Sort & Order fields // Sort & Order fields
@ -69,7 +69,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
} }
// Customer or supplier selected in drop box // Customer or supplier selected in drop box
$thirdTypeSelect = GETPOST("third_select_id"); $thirdTypeSelect = GETPOST("third_select_id");
$type_element = GETPOST('type_element')?GETPOST('type_element'):''; $type_element = GETPOSTISSET('type_element')?GETPOST('type_element'):'';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products"));
@ -173,13 +173,13 @@ if ($type_element == 'fichinter')
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, '; $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, ';
$tables_from = MAIN_DB_PREFIX.'fichinterdet d'; $tables_from = MAIN_DB_PREFIX.'fichinterdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)";
$where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')';
$dateprint = 'f.datec'; $dateprint = 'f.datec';
$doc_number='f.ref'; $doc_number='f.ref';
} }
if ($type_element == 'invoice') elseif ($type_element == 'invoice')
{ // Customer : show products from invoices { // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$documentstatic=new Facture($db); $documentstatic=new Facture($db);
@ -187,14 +187,14 @@ if ($type_element == 'invoice')
$tables_from = MAIN_DB_PREFIX.'facturedet d'; $tables_from = MAIN_DB_PREFIX.'facturedet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)";
$where = " WHERE f.entity IN (".getEntity('invoice').")"; $where = " WHERE f.entity IN (".getEntity('invoice').")";
$dateprint = 'f.datef'; $dateprint = 'f.datef';
$doc_number='f.ref'; $doc_number='f.ref';
$thirdTypeSelect='customer'; $thirdTypeSelect='customer';
} }
if ($type_element == 'propal') elseif ($type_element == 'propal')
{ {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$documentstatic=new Propal($db); $documentstatic=new Propal($db);
@ -202,14 +202,14 @@ if ($type_element == 'propal')
$tables_from = MAIN_DB_PREFIX.'propaldet d'; $tables_from = MAIN_DB_PREFIX.'propaldet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('propal').')'; $where = ' WHERE c.entity IN ('.getEntity('propal').')';
$datePrint = 'c.datep'; $datePrint = 'c.datep';
$doc_number='c.ref'; $doc_number='c.ref';
$thirdTypeSelect='customer'; $thirdTypeSelect='customer';
} }
if ($type_element == 'order') elseif ($type_element == 'order')
{ {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$documentstatic=new Commande($db); $documentstatic=new Commande($db);
@ -217,14 +217,14 @@ if ($type_element == 'order')
$tables_from = MAIN_DB_PREFIX.'commandedet d'; $tables_from = MAIN_DB_PREFIX.'commandedet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('order').')'; $where = ' WHERE c.entity IN ('.getEntity('order').')';
$dateprint = 'c.date_commande'; $dateprint = 'c.date_commande';
$doc_number='c.ref'; $doc_number='c.ref';
$thirdTypeSelect='customer'; $thirdTypeSelect='customer';
} }
if ($type_element == 'supplier_invoice') elseif ($type_element == 'supplier_invoice')
{ // Supplier : Show products from invoices. { // Supplier : Show products from invoices.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$documentstatic=new FactureFournisseur($db); $documentstatic=new FactureFournisseur($db);
@ -232,14 +232,14 @@ if ($type_element == 'supplier_invoice')
$tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)";
$where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')'; $where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')';
$dateprint = 'f.datef'; $dateprint = 'f.datef';
$doc_number='f.ref'; $doc_number='f.ref';
$thirdTypeSelect='supplier'; $thirdTypeSelect='supplier';
} }
//if ($type_element == 'supplier_proposal') //elseif ($type_element == 'supplier_proposal')
//{ //{
// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
// $documentstatic=new SupplierProposal($db); // $documentstatic=new SupplierProposal($db);
@ -252,7 +252,7 @@ if ($type_element == 'supplier_invoice')
// $doc_number='c.ref'; // $doc_number='c.ref';
// $thirdTypeSelect='supplier'; // $thirdTypeSelect='supplier';
//} //}
if ($type_element == 'supplier_order') elseif ($type_element == 'supplier_order')
{ // Supplier : Show products from orders. { // Supplier : Show products from orders.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$documentstatic=new CommandeFournisseur($db); $documentstatic=new CommandeFournisseur($db);
@ -260,14 +260,14 @@ if ($type_element == 'supplier_order')
$tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')'; $where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')';
$dateprint = 'c.date_valid'; $dateprint = 'c.date_valid';
$doc_number='c.ref'; $doc_number='c.ref';
$thirdTypeSelect='supplier'; $thirdTypeSelect='supplier';
} }
if ($type_element == 'contract') elseif ($type_element == 'contract')
{ // Order { // Order
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$documentstatic=new Contrat($db); $documentstatic=new Contrat($db);
@ -276,7 +276,7 @@ if ($type_element == 'contract')
$tables_from = MAIN_DB_PREFIX.'contratdet d'; $tables_from = MAIN_DB_PREFIX.'contratdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('contrat').')'; $where = ' WHERE c.entity IN ('.getEntity('contrat').')';
$dateprint = 'c.date_valid'; $dateprint = 'c.date_valid';

View File

@ -165,8 +165,8 @@ $arrayfields=array(
'p.fax'=>array('label'=>"Fax", 'checked'=>0), 'p.fax'=>array('label'=>"Fax", 'checked'=>0),
'p.email'=>array('label'=>"EMail", 'checked'=>1), 'p.email'=>array('label'=>"EMail", 'checked'=>1),
'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))), 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))),
'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
'p.linkedin'=>array('label'=>"LinkedIn", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.linkedin'=>array('label'=>"LinkedIn", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
@ -427,7 +427,7 @@ if ($search_societe != '') $param.='&amp;search_societe='.urlencode($search_soci
if ($search_zip != '') $param.='&amp;search_zip='.urlencode($search_zip); if ($search_zip != '') $param.='&amp;search_zip='.urlencode($search_zip);
if ($search_town != '') $param.='&amp;search_town='.urlencode($search_town); if ($search_town != '') $param.='&amp;search_town='.urlencode($search_town);
if ($search_country != '') $param.= "&search_country=".urlencode($search_country); if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
if ($search_job != '') $param.='&amp;search_job='.urlencode($search_job); if ($search_poste != '') $param.='&amp;search_poste='.urlencode($search_poste);
if ($search_phone_pro != '') $param.='&amp;search_phone_pro='.urlencode($search_phone_pro); if ($search_phone_pro != '') $param.='&amp;search_phone_pro='.urlencode($search_phone_pro);
if ($search_phone_perso != '') $param.='&amp;search_phone_perso='.urlencode($search_phone_perso); if ($search_phone_perso != '') $param.='&amp;search_phone_perso='.urlencode($search_phone_perso);
if ($search_phone_mobile != '') $param.='&amp;search_phone_mobile='.urlencode($search_phone_mobile); if ($search_phone_mobile != '') $param.='&amp;search_phone_mobile='.urlencode($search_phone_mobile);
@ -629,6 +629,12 @@ if (! empty($arrayfields['p.skype']['checked']))
print '<input class="flat" type="text" name="search_skype" size="6" value="'.dol_escape_htmltag($search_skype).'">'; print '<input class="flat" type="text" name="search_skype" size="6" value="'.dol_escape_htmltag($search_skype).'">';
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['p.jabberid']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_jabberid" size="6" value="'.dol_escape_htmltag($search_jabberid).'">';
print '</td>';
}
if (! empty($arrayfields['p.twitter']['checked'])) if (! empty($arrayfields['p.twitter']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
@ -720,6 +726,7 @@ if (! empty($arrayfields['p.fax']['checked'])) print_liste_field
if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.jabberid']['checked'])) print_liste_field_titre($arrayfields['p.jabberid']['label'], $_SERVER["PHP_SELF"], "p.jabberid", $begin, $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.linkedin']['checked'])) print_liste_field_titre($arrayfields['p.linkedin']['label'], $_SERVER["PHP_SELF"], "p.linkedin", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.linkedin']['checked'])) print_liste_field_titre($arrayfields['p.linkedin']['label'], $_SERVER["PHP_SELF"], "p.linkedin", $begin, $param, '', $sortfield, $sortorder);

View File

@ -96,6 +96,12 @@ class Contrat extends CommonObject
*/ */
public $ref_supplier; public $ref_supplier;
/**
* Entity of the contract
* @var int
*/
public $entity;
/** /**
* Client id linked to the contract * Client id linked to the contract
* @var int * @var int
@ -245,7 +251,7 @@ class Contrat extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Contract"));
return ""; return "";
} }
} }
@ -486,13 +492,18 @@ class Contrat extends CommonObject
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// Rename of object directory ($this->ref = old ref, $num = new ref) // Now we rename also files into index
// to not lose the linked files $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->db->escape($this->newref)."'";
$sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->contract->dir_output.'/'.$oldref; $dirsource = $conf->contract->dir_output.'/'.$oldref;
$dirdest = $conf->contract->dir_output.'/'.$newref; $dirdest = $conf->contract->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (! $error && file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
@ -612,13 +623,14 @@ class Contrat extends CommonObject
* @param string $ref Ref * @param string $ref Ref
* @param string $ref_customer Customer ref * @param string $ref_customer Customer ref
* @param string $ref_supplier Supplier ref * @param string $ref_supplier Supplier ref
* @return int <0 if KO, 0 if not found, Id of contract if OK * @return int <0 if KO, 0 if not found or if two records found for same ref, Id of contract if OK
*/ */
public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '')
{ {
$sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,";
$sql.= " ref_supplier, ref_customer,"; $sql.= " ref_supplier, ref_customer,";
$sql.= " ref_ext,"; $sql.= " ref_ext,";
$sql.= " entity,";
$sql.= " fk_user_mise_en_service, date_contrat as datecontrat,"; $sql.= " fk_user_mise_en_service, date_contrat as datecontrat,";
$sql.= " fk_user_author, fin_validite, date_cloture,"; $sql.= " fk_user_author, fin_validite, date_cloture,";
$sql.= " fk_projet as fk_project,"; $sql.= " fk_projet as fk_project,";
@ -644,57 +656,67 @@ class Contrat extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $num=$this->db->num_rows($resql);
if ($num > 1)
if ($obj)
{ {
$this->id = $obj->rowid; $this->error='Fetch found several records.';
$this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; dol_syslog($this->error, LOG_ERR);
$this->ref_customer = $obj->ref_customer; $result = -2;
$this->ref_supplier = $obj->ref_supplier; }
$this->ref_ext = $obj->ref_ext; elseif ($num) // $num = 1
$this->statut = $obj->statut; {
$this->mise_en_service = $this->db->jdate($obj->datemise); $obj = $this->db->fetch_object($resql);
if ($obj)
$this->date_contrat = $this->db->jdate($obj->datecontrat);
$this->date_creation = $this->db->jdate($obj->datecontrat);
$this->fin_validite = $this->db->jdate($obj->fin_validite);
$this->date_cloture = $this->db->jdate($obj->date_cloture);
$this->user_author_id = $obj->fk_user_author;
$this->commercial_signature_id = $obj->fk_commercial_signature;
$this->commercial_suivi_id = $obj->fk_commercial_suivi;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf;
$this->fk_projet = $obj->fk_project; // deprecated
$this->fk_project = $obj->fk_project;
$this->socid = $obj->fk_soc;
$this->fk_soc = $obj->fk_soc;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql);
// Retreive all extrafields
// fetch optionals attributes and labels
$this->fetch_optionals();
// Lines
$result=$this->fetch_lines();
if ($result < 0)
{ {
$this->error=$this->db->lasterror(); $this->id = $obj->rowid;
return -3; $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref;
} $this->ref_customer = $obj->ref_customer;
$this->ref_supplier = $obj->ref_supplier;
$this->ref_ext = $obj->ref_ext;
$this->entity = $obj->entity;
$this->statut = $obj->statut;
$this->mise_en_service = $this->db->jdate($obj->datemise);
return $this->id; $this->date_contrat = $this->db->jdate($obj->datecontrat);
$this->date_creation = $this->db->jdate($obj->datecontrat);
$this->fin_validite = $this->db->jdate($obj->fin_validite);
$this->date_cloture = $this->db->jdate($obj->date_cloture);
$this->user_author_id = $obj->fk_user_author;
$this->commercial_signature_id = $obj->fk_commercial_signature;
$this->commercial_suivi_id = $obj->fk_commercial_suivi;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf;
$this->fk_projet = $obj->fk_project; // deprecated
$this->fk_project = $obj->fk_project;
$this->socid = $obj->fk_soc;
$this->fk_soc = $obj->fk_soc;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql);
// Retreive all extrafields
// fetch optionals attributes and labels
$this->fetch_optionals();
// Lines
$result=$this->fetch_lines();
if ($result < 0)
{
$this->error=$this->db->lasterror();
return -3;
}
return $this->id;
}
} }
else else
{ {
@ -2181,23 +2203,27 @@ class Contrat extends CommonObject
if ($mode == 'inactive') { if ($mode == 'inactive') {
$warning_delay = $conf->contrat->services->inactifs->warning_delay; $warning_delay = $conf->contrat->services->inactifs->warning_delay;
$label = $langs->trans("BoardNotActivatedServices"); $label = $langs->trans("BoardNotActivatedServices");
$labelShort = $langs->trans("BoardNotActivatedServicesShort");
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc';
} }
elseif ($mode == 'expired') { elseif ($mode == 'expired') {
$warning_delay = $conf->contrat->services->expires->warning_delay; $warning_delay = $conf->contrat->services->expires->warning_delay;
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc';
$label = $langs->trans("BoardExpiredServices"); $label = $langs->trans("BoardExpiredServices");
$labelShort = $langs->trans("BoardExpiredServicesShort");
} else { } else {
$warning_delay = $conf->contrat->services->expires->warning_delay; $warning_delay = $conf->contrat->services->expires->warning_delay;
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc'; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc';
//$url.= '&op2day='.$arraydatetouse['mday'].'&op2month='.$arraydatetouse['mon'].'&op2year='.$arraydatetouse['year']; //$url.= '&op2day='.$arraydatetouse['mday'].'&op2month='.$arraydatetouse['mon'].'&op2year='.$arraydatetouse['year'];
//if ($warning_delay >= 0) $url.='&amp;filter=expired'; //if ($warning_delay >= 0) $url.='&amp;filter=expired';
$label = $langs->trans("BoardRunningServices"); $label = $langs->trans("BoardRunningServices");
$labelShort = $langs->trans("BoardRunningServicesShort");
} }
$response = new WorkboardResponse(); $response = new WorkboardResponse();
$response->warning_delay = $warning_delay/60/60/24; $response->warning_delay = $warning_delay/60/60/24;
$response->label = $label; $response->label = $label;
$response->labelShort = $labelShort;
$response->url = $url; $response->url = $url;
$response->img = img_object('', "contract"); $response->img = img_object('', "contract");

View File

@ -125,8 +125,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
{ {
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
$link = new Link($db); $link = new Link($db);
$link->id = $linkid; $link->fetch($linkid);
$link->fetch();
$res = $link->delete($user); $res = $link->delete($user);
$langs->load('link'); $langs->load('link');
@ -160,8 +159,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
$langs->load('link'); $langs->load('link');
$link = new Link($db); $link = new Link($db);
$link->id = GETPOST('linkid', 'int'); $f = $link->fetch(GETPOST('linkid', 'int'));
$f = $link->fetch();
if ($f) if ($f)
{ {
$link->url = GETPOST('link', 'alpha'); $link->url = GETPOST('link', 'alpha');
@ -169,7 +167,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('
{ {
$link->url = 'http://' . $link->url; $link->url = 'http://' . $link->url;
} }
$link->label = GETPOST('label', 'alpha'); $link->label = GETPOST('label', 'alphanohtml');
$res = $link->update($user); $res = $link->update($user);
if (!$res) if (!$res)
{ {

View File

@ -17,7 +17,7 @@
/** /**
* \file /htdocs/core/ajax/extraparams.php * \file /htdocs/core/ajax/extraparams.php
* \brief File to return Ajax response on set extra parameters of elements * \brief File to make Ajax action on setting extra parameters of elements
*/ */
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal

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