Merge branch 'develop' into patch-17

This commit is contained in:
Laurent Destailleur 2020-03-03 23:24:14 +01:00 committed by GitHub
commit 88059a52d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
335 changed files with 44288 additions and 40367 deletions

View File

@ -3,21 +3,23 @@ name: "Close stale issues (bugs and feature requests)"
on: on:
schedule: schedule:
- cron: "0 0 * * *" - cron: "0 20 * * *"
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@v1 - uses: Dolibarr/stale@master
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.' stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.'
stale-issue-label: 'Issue Stale (automatic label)' stale-issue-label: 'Issue Stale (automatic label)'
exempt-issue-label: 'Priority High / Blocking' exempt-issue-label: 'Priority High / Blocking'
days-before-stale: 365 days-before-stale: 365
days-before-close: 10 days-before-close: 15
operations-per-run: 50
#stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.' #stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.'
#stale-pr-label: 'PR Stale (automatic label)' stale-pr-label: 'PR Stale (automatic label)'
#exempt-pr-label: 'Priority Top Strategic' stale-pr-message:
exempt-pr-label: 'Priority Top Strategic'

View File

@ -3,6 +3,7 @@
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/
# We use dist: xenial to have php 5.6+ available # We use dist: xenial to have php 5.6+ available
os: linux
dist: xenial dist: xenial
sudo: required sudo: required
@ -43,7 +44,7 @@ env:
global: global:
# Set to true for very verbose output # Set to true for very verbose output
- DEBUG=false - DEBUG=false
matrix: jobs:
# MariaDB overrides MySQL installation so it's not possible to test both yet # MariaDB overrides MySQL installation so it's not possible to test both yet
#- DB=mariadb #- DB=mariadb
- DB=mysql - DB=mysql
@ -53,7 +54,7 @@ env:
# See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test
#- WS=nginx #- WS=nginx
matrix: jobs:
fast_finish: true fast_finish: true
allow_failures: allow_failures:
- php: nightly - php: nightly

View File

@ -18,8 +18,9 @@ Following changes may create regressions for some external modules, but were nec
* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests * Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests
with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing
the HTML into content (in such a case, sanitize data later) the HTML into content (in such a case, sanitize data later)
* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless.
* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced
by a "_" automatically when a reference is generated.
***** ChangeLog for 11.0.1 compared to 11.0.0 ***** ***** ChangeLog for 11.0.1 compared to 11.0.0 *****
FIX: advanced target emailing sql and ergonomy. FIX: advanced target emailing sql and ergonomy.

View File

@ -45,9 +45,12 @@ Dolibarr working. It is here only to build Dolibarr packages, and those
generated packages will not contains this "build" directory. generated packages will not contains this "build" directory.
We can find in "build", following sub-directories: You can find in "build", following sub-directories:
* debian: * composer
To test an upgrade of a lib.
* debian
To build Debian package. To build Debian package.
* dmg: * dmg:

View File

@ -1,20 +1,24 @@
README (English) README (English)
################################################## ##################################################
OBS Package tools OBS Package tools
OBE - openSUSE Build Service
################################################## ##################################################
This directory contains files to explain how to publish This directory contains an instruction to explain
a package onto OBS how to publish a package onto OBS.
# Create a project onto OBS # Create a project onto OBS
#---------------------------------- ---------------------------
https://build.opensuse.org https://build.opensuse.org
Packaging rules: http://en.opensuse.org/Portal:Packaging
# Packaging rules:
------------------
https://en.opensuse.org/Portal:Packaging
Add attributes: Add attributes:
OBS:Screenshots URL of screenshot http://www.dolibarr.org/images/dolibarr_screenshot1.png OBS:Screenshots URL of screenshot https://www.dolibarr.org/images/dolibarr_screenshot1.png
OBS:QualityCategory Development|Testing|Stable|Private OBS:QualityCategory Development|Testing|Stable|Private
OBS:Maintained 1 OBS:Maintained 1
@ -28,22 +32,24 @@ To submit a snapshot for building, we should have a service file with content
</service> </service>
</services> </services>
How to have such a service file created automatically ?
Go into project you want to update. It mught be: # How to have such a service file created automatically ?
---------------------------------------------------------
Go into project you want to update. It might be:
- openSUSE Build Service > Projects > Application:ERP:Dolibarr > dolibarr - openSUSE Build Service > Projects > Application:ERP:Dolibarr > dolibarr
- or your private project - or your private project
Once logged, click on "Add file" in section "Source Files", then select mode "Upload From: Remote URL" Once logged, click on "Add file" in section "Source Files", then select mode "Upload From: Remote URL"
Keep empty for "Filename", choose "Remote URL" and enter into last field, URL that should looks like this: Keep empty for "Filename", choose "Remote URL" and enter into last field, URL that should looks like this:
http://www.dolibarr.org/files/stable/package_rpm_generic/dolibarr-x.y.v-0.4.src.rpm https://www.dolibarr.org/files/stable/package_rpm_generic/dolibarr-x.y.v-0.4.src.rpm
Then add into Advanded - Attributes Then add into Advanded - Attributes
OBS:Screenshots http://www.dolibarr.org/images/dolibarr_screenshot1.png OBS:Screenshots https://www.dolibarr.org/images/dolibarr_screenshot1.png
OBS:QualityCategory Stable|Testing|Development|Private OBS:QualityCategory Stable|Testing|Development|Private
# Move project into official directory # Move project into official directory
--------------------------------------
- Enter a bug to ask to be a maintener of a category or to add a new one. - Enter a bug to ask to be a maintener of a category or to add a new one.
For example: https://bugzilla.novell.com/show_bug.cgi?id=848083 to be a maintener of category For example: https://bugzilla.novell.com/show_bug.cgi?id=848083 to be a maintener of category
https://build.opensuse.org/project/show/Application:ERP https://build.opensuse.org/project/show/Application:ERP

View File

@ -11,4 +11,4 @@ objectclass: dcObject
objectClass: organization objectClass: organization
objectClass: top objectClass: top
dc: my-domain dc: my-domain
o: Mon organisation o: my organisation

View File

@ -12,4 +12,4 @@ objectclass: dcObject
objectClass: organization objectClass: organization
objectClass: top objectClass: top
dc: my-domain dc: my-domain
o: Mon organisation o: my organisation

View File

@ -1,7 +1,7 @@
* Page with licence compatibility * Page with license compatibility
https://www.gnu.org/licenses/quick-guide-gplv3.fr.html https://www.gnu.org/licenses/quick-guide-gplv3.fr.html
* FAQ on GPL licence * FAQ on GPL license
https://www.fsf.org/licensing/licenses/gpl-faq.html https://www.fsf.org/licensing/licenses/gpl-faq.html
* Questions/Answers on Fork for using Dolibarr as a SaaS * Questions/Answers on Fork for using Dolibarr as a SaaS

View File

@ -1,2 +1,2 @@
To test a SEPA file: To test a SEPA file:
http://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa https://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa

View File

@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT ruleset (description,exclude-pattern*,rule+)> <!ELEMENT ruleset (description,arg*,exclude-pattern*,rule+)>
<!ATTLIST ruleset name CDATA ""> <!ATTLIST ruleset name CDATA "">
<!ELEMENT description (#PCDATA)> <!ELEMENT description (#PCDATA)>
<!ELEMENT arg (#PCDATA)>
<!ATTLIST arg name CDATA "">
<!ATTLIST arg value CDATA "">
<!ELEMENT exclude-pattern (#PCDATA)> <!ELEMENT exclude-pattern (#PCDATA)>
<!ATTLIST exclude-pattern type CDATA ""> <!ATTLIST exclude-pattern type CDATA "">
<!ELEMENT rule (properties*,severity*)> <!ELEMENT rule (properties*,severity*,exclude*)>
<!ATTLIST rule ref CDATA ""> <!ATTLIST rule ref CDATA "">
<!ELEMENT properties (property+)> <!ELEMENT properties (property+)>
<!ELEMENT property (#PCDATA)> <!ELEMENT property (#PCDATA)>
<!ATTLIST property name CDATA ""> <!ATTLIST property name CDATA "">
<!ATTLIST property value CDATA ""> <!ATTLIST property value CDATA "">
<!ELEMENT severity (#PCDATA)> <!ELEMENT severity (#PCDATA)>
<!ELEMENT exclude (#PCDATA)>
<!ATTLIST exclude name CDATA "">

View File

@ -2,6 +2,7 @@
<!DOCTYPE ruleset SYSTEM "ruleset.dtd"> <!DOCTYPE ruleset SYSTEM "ruleset.dtd">
<ruleset name="Dolibarr"> <ruleset name="Dolibarr">
<description>Dolibarr coding standard.</description> <description>Dolibarr coding standard.</description>
<arg name="tab-width" value="4"/>
<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>
@ -188,7 +189,6 @@
<!-- Disabled as this does not support tab --> <!-- Disabled as this does not support tab -->
<!-- <rule ref="Generic.WhiteSpace.ScopeIndent" /> --> <!-- <rule ref="Generic.WhiteSpace.ScopeIndent" /> -->
<arg name="tab-width" value="4"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"> <rule ref="Generic.WhiteSpace.ScopeIndent">
<properties> <properties>
<property name="indent" value="4"/> <property name="indent" value="4"/>

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles>
<profile name="PSR-12 [built-in]">
<setting id="indentationChar" value="&#9;"/>
<setting id="insert_space_after_opening_paren_in_declare" value="false"/>
<setting id="insert_space_before_closing_paren_in_declare" value="false"/>
<setting id="insert_space_before_opening_paren_in_declare" value="false"/>
<setting id="org.eclipse.php.core.formatter.insert_new_line_in_function_invoke" value="3"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_method_invocation_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_method_invocation_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_method_invocation_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_assignment_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_assignment_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_assignment_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_binary_expression_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_binary_expression_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_binary_expression_line_wrap_policy" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_compact_if_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_compact_if_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_compact_if_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_conditional_expression_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_conditional_expression_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_conditional_expression_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_expressions_in_array_initializer_force_split" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_expressions_in_array_initializer_indent_policy" value="2"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_expressions_in_array_initializer_line_wrap_policy" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_parameters_in_method_declaration_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_parameters_in_method_declaration_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_parameters_in_method_declaration_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_superclass_in_type_declaration_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_superclass_in_type_declaration_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_superclass_in_type_declaration_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_superinterfaces_in_type_declaration_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_superinterfaces_in_type_declaration_indent_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_superinterfaces_in_type_declaration_line_wrap_policy" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.blank_lines_before_field" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.brace_position_for_block" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.brace_position_for_lambda_function_declaration" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.brace_position_for_method_declaration" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.brace_position_for_switch" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.brace_position_for_type_declaration" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.format_javadoc_comments" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.insert_new_line_before_root_tags" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.insert_new_line_for_parameter" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.keep_empty_line_for_empty_description" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.line_length" value="1000"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.never_format_unknown_tags" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.continuation_indentation" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.continuation_indentation_for_array_initializer" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.php.formatter.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.php.formatter.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_heredocs" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.indentation.size" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_before_catch_in_try_statement" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_before_else_in_if_statement" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_before_finally_in_try_statement" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_before_while_in_do_statement" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_in_empty_block" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_in_empty_method_body" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_new_line_in_empty_type_declaration" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_arrow_in_array_creation" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_arrow_in_field_access" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_arrow_in_foreach" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_arrow_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_arrow_in_yield" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_assignment_operator" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_binary_operator" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_closing_brace_in_block" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_closing_paren_in_cast" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_colon_in_conditional" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_coloncolon_in_field_access" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_coloncolon_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_array_creation" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_echo" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_for_inits" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_global" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_list" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_multiple_constant_declarations" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_static" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_comma_in_superinterfaces" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_array_creation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_cast" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_catch" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_for" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_foreach" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_if" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_list" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_switch" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_opening_paren_in_while" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_postfix_operator" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_prefix_operator" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_question_in_conditional" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_reference_symbol_in_referenced_expression" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_semicolon_in_for" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_after_unary_operator" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_arrow_in_array_creation" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_arrow_in_field_access" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_arrow_in_foreach" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_arrow_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_arrow_in_yield" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_assignment_operator" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_binary_operator" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_array_creation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_cast" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_catch" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_for" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_foreach" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_if" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_list" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_switch" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_closing_paren_in_while" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_colon_in_case" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_colon_in_conditional" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_colon_in_default" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_coloncolon_in_field_access" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_coloncolon_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_array_creation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_echo" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_for_inits" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_global" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_list" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_multiple_constant_declarations" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_static" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_comma_in_superinterfaces" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_brace_in_block" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_brace_in_switch" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_array_creation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_catch" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_for" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_foreach" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_if" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_list" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_switch" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_opening_paren_in_while" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_postfix_operator" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_prefix_operator" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_question_in_conditional" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_semicolon" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_semicolon_in_for" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_before_unary_operator" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_between_brackets_in_array_type_reference" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.keep_elseif_statement_on_same_line" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.keep_imple_if_on_one_line" value="true"/>
<setting id="org.eclipse.php.formatter.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.keep_trailing_comma_in_list" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.lineSplit" value="200"/>
<setting id="org.eclipse.php.formatter.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_after_namespace" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_after_use_statements" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_at_end_of_class_body" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_before_namespace" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_before_use_statements" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_between_namespaces" value="1"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_blank_lines_between_use_statements" value="0"/>
<setting id="org.eclipse.php.formatter.core.formatter.number_of_empty_lines_to_preserve" value="3"/>
<setting id="org.eclipse.php.formatter.core.formatter.put_empty_statement_on_new_line" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.php.formatter.core.formatter.use_on_off_tags" value="false"/>
</profile>
</profiles>

View File

@ -3,9 +3,10 @@ README (English)
This directory contains tools to generate translation files for a new This directory contains tools to generate translation files for a new
languages or to update translation files for existing languages. languages or to update translation files for existing languages.
See Dolibarr Wiki page: See Dolibarr Wiki page:
http://wiki.dolibarr.org/index.php/Translator_documentation https://wiki.dolibarr.org/index.php/Translator_documentation
For more information on how to use them. For more information on how to use them.
for Linux OS:
To install transifex client: To install transifex client:
sudo pip install --upgrade transifex-client sudo pip install --upgrade transifex-client

View File

@ -1,17 +1,25 @@
comparison of terms
Term Dolibarr SAP Odoo ... Dolibarr SAP ERP Odoo
---------------------------------------------------------------------------- -------------------------------------------------------------------------
Thirdparty Contact partner Partner/Contact (company) Thirdparty Contact partner Partner/Contact (company)
Contact/address Contact person Partner/Contact (individual) Contact/address Contact person Partner/Contact (individual)
Financial ?? Invoicing Financial Finance (FI) Accounting
Accounting
Income / Expense ?? Profit / Loss
Balance ?? Net profit
Subledger account Subledger account ??
Proposal ?? Quotation Proposal is ok but proposition looks better (proposal is for a detailed proposition). We can say also "business proposition or business proposal". Income / Expense ?? Profit / Loss
Indian are using "Quotation". Balance ?? Net profit
Subledger account Subledger account ??
CRM Sales & Distribution Sales
Proposal ?? Quotation
Proposal is ok but proposition looks better (proposal is for a detailed proposition).
We can say also "business proposition or business proposal".
In India they are using "Quotation".

12
doc/user/README-DE.md Normal file
View File

@ -0,0 +1,12 @@
README (german)
LiesMich (deutsch)
--------------------------------
Benutzeranleitung
--------------------------------
Alle Dolibarr-Informationen sind online verfuegbar ueber die Webseiten:
https://www.dolibarr.de
oder
https://www.dolibarr.org
https://wiki.dolibarr.org

View File

@ -45,7 +45,8 @@ $search_label = GETPOST('search_label', 'alpha');
$search_labelshort = GETPOST('search_labelshort', 'alpha'); $search_labelshort = GETPOST('search_labelshort', 'alpha');
$search_accountparent = GETPOST('search_accountparent', 'alpha'); $search_accountparent = GETPOST('search_accountparent', 'alpha');
$search_pcgtype = GETPOST('search_pcgtype', 'alpha'); $search_pcgtype = GETPOST('search_pcgtype', 'alpha');
$search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha');
$chartofaccounts = GETPOST('chartofaccounts', 'int');
// Security check // Security check
if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) accessforbidden();
@ -69,8 +70,7 @@ $arrayfields = array(
'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
); );
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
@ -101,14 +101,11 @@ if (empty($reshook))
$search_labelshort = ""; $search_labelshort = "";
$search_accountparent = ""; $search_accountparent = "";
$search_pcgtype = ""; $search_pcgtype = "";
$search_pcgsubtype = "";
$search_array_options = array(); $search_array_options = array();
} }
if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax))) || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified
{ {
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if ($chartofaccounts > 0) if ($chartofaccounts > 0)
{ {
// Get language code for this $chartofaccounts // Get language code for this $chartofaccounts
@ -195,7 +192,7 @@ if ($action == 'delete') {
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.active, "; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.active, ";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
@ -241,7 +238,6 @@ if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_la
if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort); if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort);
if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2); if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2);
if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype);
if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype);
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
@ -274,23 +270,17 @@ if ($resql)
if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort); if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort);
if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); if ($optioncss != '') $param .= '&optioncss='.$optioncss;
if ($optioncss != '') $param .= '&optioncss='.$optioncss;
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax))
{ {
print '<!-- Add javascript to update a flag when we select "Change plan" --> print '<!-- Add javascript to reload page when we click "Change plan" -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$("#searchFormList").on("submit", function (e) { $("#change_chart").on("click", function (e) {
console.log("chartofaccounts focus = "+$("#chartofaccounts").is(":focus")); console.log("chartofaccounts seleted = "+$("#chartofaccounts").val());
console.log("change_chart focus = "+$("#change_chart").is(":focus")); // reload page
if ($("#change_chart").is(":focus")) window.location.href = "'.$_SERVER["PHP_SELF"].'?valid_change_chart=1&chartofaccounts="+$("#chartofaccounts").val();
{
console.log("We set valid_change_chart to 1");
$("#valid_change_chart").val(1);
}
return true;
}); });
}); });
</script>'; </script>';
@ -337,8 +327,7 @@ if ($resql)
else dol_print_error($db); else dol_print_error($db);
print "</select>"; print "</select>";
print ajax_combobox("chartofaccounts"); print ajax_combobox("chartofaccounts");
print '<input type="submit" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">'; print '<input type="'.(empty($conf->use_javascript_ajax)?'submit':'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
print '<input type="hidden" name="valid_change_chart" id="valid_change_chart" value="0">';
print '<br>'; print '<br>';
print '<br>'; print '<br>';
@ -363,7 +352,6 @@ if ($resql)
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>'; if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="'.$search_pcgsubtype.'"></td>';
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
@ -377,7 +365,6 @@ if ($resql)
if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']);
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -454,15 +441,6 @@ if ($resql)
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Chart of accounts subtype
if (!empty($arrayfields['aa.pcg_subtype']['checked']))
{
print "<td>";
print $obj->pcg_subtype;
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Activated or not // Activated or not
if (!empty($arrayfields['aa.active']['checked'])) if (!empty($arrayfields['aa.active']['checked']))
{ {

View File

@ -92,7 +92,6 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->fk_pcg_version = $obj->pcg_version; $object->fk_pcg_version = $obj->pcg_version;
$object->pcg_type = GETPOST('pcg_type', 'alpha'); $object->pcg_type = GETPOST('pcg_type', 'alpha');
$object->pcg_subtype = GETPOST('pcg_subtype', 'alpha');
$object->account_number = $account_number; $object->account_number = $account_number;
$object->account_parent = $account_parent; $object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category', 'alpha'); $object->account_category = GETPOST('account_category', 'alpha');
@ -158,7 +157,6 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->fk_pcg_version = $obj->pcg_version; $object->fk_pcg_version = $obj->pcg_version;
$object->pcg_type = GETPOST('pcg_type', 'alpha'); $object->pcg_type = GETPOST('pcg_type', 'alpha');
$object->pcg_subtype = GETPOST('pcg_subtype', 'alpha');
$object->account_number = $account_number; $object->account_number = $account_number;
$object->account_parent = $account_parent; $object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category', 'alpha'); $object->account_category = GETPOST('account_category', 'alpha');
@ -260,12 +258,6 @@ if ($action == 'create') {
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">'; print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>'; print '</td></tr>';
// Chart of accounts subtype
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
print '</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
@ -329,12 +321,6 @@ elseif ($id > 0 || $ref) {
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">'; print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>'; print '</td></tr>';
// Chart of accounts subtype
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
print '</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
@ -383,10 +369,6 @@ elseif ($id > 0 || $ref) {
print '<tr><td>'.$langs->trans("Pcgtype").'</td>'; print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td colspan="2">'.$object->pcg_type.'</td></tr>'; print '<td colspan="2">'.$object->pcg_type.'</td></tr>';
// Chart of accounts subtype
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td colspan="2">'.$object->pcg_subtype.'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@ -677,9 +677,6 @@ if ($id)
} }
if ($fieldlist[$field] == 'pcg_type') { if ($fieldlist[$field] == 'pcg_type') {
$valuetoshow = $langs->trans("Pcg_type"); $valuetoshow = $langs->trans("Pcg_type");
}
if ($fieldlist[$field] == 'pcg_subtype') {
$valuetoshow = $langs->trans("Pcg_subtype");
} }
if ($fieldlist[$field] == 'type_template') { if ($fieldlist[$field] == 'type_template') {
$valuetoshow = $langs->trans("TypeOfTemplate"); $valuetoshow = $langs->trans("TypeOfTemplate");

View File

@ -161,6 +161,7 @@ print '<input type="hidden" name="action" value="update">';
// Define main accounts for thirdparty // Define main accounts for thirdparty
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("ThirdParties").' | '.$langs->trans("Users").'</td><td></td></tr>';
foreach ($list_account_main as $key) { foreach ($list_account_main as $key) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
@ -180,15 +181,6 @@ foreach ($list_account_main as $key) {
} }
print "</table>\n";
print '<br>';
// Define default accounts
print '<table class="noborder centpercent">';
foreach ($list_account as $key) { foreach ($list_account as $key) {
$reg=array(); $reg=array();
if (preg_match('/---(.*)---/', $key, $reg)) { if (preg_match('/---(.*)---/', $key, $reg)) {

View File

@ -134,13 +134,13 @@ if ($action == 'update') {
$form = new Form($db); $form = new Form($db);
$title = $langs->trans('ConfigAccountingExpert'); $title = $langs->trans('ExportOptions');
llxHeader('', $title); llxHeader('', $title);
$linkback = ''; $linkback = '';
// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>'; // $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy'); print load_fiche_titre($langs->trans('ExportOptions'), $linkback, 'accountancy');
print "\n".'<script type="text/javascript" language="javascript">'."\n"; print "\n".'<script type="text/javascript" language="javascript">'."\n";

View File

@ -268,11 +268,11 @@ if ($action != 'export_csv')
$displayed_account = ""; $displayed_account = "";
$sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity; $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity;
$sql.= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte";
$resql = $db->query($sql); $resql = $db->query($sql);
$nrows = $resql->num_rows; $nrows = $resql->num_rows;
$opening_balances = Array(); $opening_balances = Array();
for($i = 0; $i < $nrows; $i++) { for ($i = 0; $i < $nrows; $i++) {
$arr = $resql->fetch_array(); $arr = $resql->fetch_array();
$opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance']; $opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance'];
} }
@ -294,14 +294,14 @@ if ($action != 'export_csv')
{ {
// Affiche un Sous-Total par compte comptable // Affiche un Sous-Total par compte comptable
if ($displayed_account != "") { if ($displayed_account != "") {
print '<tr class="liste_total"><td class="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap right">' . price($sous_total_debit) . '</td><td class="nowrap right">' . price($sous_total_credit) . '</td><td class="nowrap right">' . price(price2num($sous_total_credit - $sous_total_debit)) . '</td>'; print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_credit - $sous_total_debit)).'</td>';
print "<td>&nbsp;</td>\n"; print "<td>&nbsp;</td>\n";
print '</tr>'; print '</tr>';
} }
// Show first line of a break // Show first line of a break
print '<tr class="trforbreak">'; print '<tr class="trforbreak">';
print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">' . $line->numero_compte . ($root_account_description ? ' - ' . $root_account_description : '') . '</td>'; print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>'; print '</tr>';
$displayed_account = $root_account_description; $displayed_account = $root_account_description;

View File

@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@ -538,6 +539,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
*/ */
$formother = new FormOther($db); $formother = new FormOther($db);
$formfile = new FormFile($db);
$title_page = $langs->trans("Bookkeeping"); $title_page = $langs->trans("Bookkeeping");
@ -914,7 +916,69 @@ while ($i < min($num, $limit))
// Document ref // Document ref
if (!empty($arrayfields['t.doc_ref']['checked'])) if (!empty($arrayfields['t.doc_ref']['checked']))
{ {
print '<td class="nowrap">'.$line->doc_ref.'</td>'; if ($line->doc_type == 'customer_invoice')
{
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$objectstatic = new Facture($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'facture';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
}
elseif ($line->doc_type == 'supplier_invoice')
{
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$objectstatic = new FactureFournisseur($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'invoice_supplier';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
}
elseif ($line->doc_type == 'expense_report')
{
$langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$objectstatic = new ExpenseReport($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'expensereport';
$filename=dol_sanitizeFileName($line->doc_ref);
$filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
}
else
{
// Other type
}
print '<td class="nowrap">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref
print '<td class="nobordernopadding nowrap">';
if($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
{
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink;
} else {
print $line->doc_ref;
}
print '</td></tr></table>';
print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }

View File

@ -239,7 +239,7 @@ class AccountancyExport
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
$type_export = 'general_ledger'; $type_export = 'general_ledger';
global $db; // The tpl file use $db global $db; // The tpl file use $db
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
@ -983,7 +983,7 @@ class AccountancyExport
$racine_subledger_account = ''; // for records of type E leave this field blank $racine_subledger_account = ''; // for records of type E leave this field blank
// } // }
print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
// MONT // MONT
print price(abs($line->montant), 0, '', 1, 2).$separator; print price(abs($line->montant), 0, '', 1, 2).$separator;
// CODC // CODC

View File

@ -53,11 +53,6 @@ class AccountancySystem
*/ */
public $pcg_type; public $pcg_type;
/**
* @var string pcg subtype
*/
public $pcg_subtype;
/** /**
* @var string Accountancy System numero * @var string Accountancy System numero
*/ */

View File

@ -90,11 +90,6 @@ class AccountingAccount extends CommonObject
*/ */
public $pcg_type; public $pcg_type;
/**
* @var string pcg subtype
*/
public $pcg_subtype;
/** /**
* @var string account number * @var string account number
*/ */
@ -167,7 +162,7 @@ class AccountingAccount extends CommonObject
global $conf; global $conf;
if ($rowid || $account_number) { if ($rowid || $account_number) {
$sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active"; $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
$sql .= ", ca.label as category_label"; $sql .= ", ca.label as category_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
@ -198,7 +193,6 @@ class AccountingAccount extends CommonObject
$this->tms = $obj->tms; $this->tms = $obj->tms;
$this->fk_pcg_version = $obj->fk_pcg_version; $this->fk_pcg_version = $obj->fk_pcg_version;
$this->pcg_type = $obj->pcg_type; $this->pcg_type = $obj->pcg_type;
$this->pcg_subtype = $obj->pcg_subtype;
$this->account_number = $obj->account_number; $this->account_number = $obj->account_number;
$this->account_parent = $obj->account_parent; $this->account_parent = $obj->account_parent;
$this->label = $obj->label; $this->label = $obj->label;
@ -240,8 +234,6 @@ class AccountingAccount extends CommonObject
$this->fk_pcg_version = trim($this->fk_pcg_version); $this->fk_pcg_version = trim($this->fk_pcg_version);
if (isset($this->pcg_type)) if (isset($this->pcg_type))
$this->pcg_type = trim($this->pcg_type); $this->pcg_type = trim($this->pcg_type);
if (isset($this->pcg_subtype))
$this->pcg_subtype = trim($this->pcg_subtype);
if (isset($this->account_number)) if (isset($this->account_number))
$this->account_number = trim($this->account_number); $this->account_number = trim($this->account_number);
if (isset($this->label)) if (isset($this->label))
@ -253,10 +245,6 @@ class AccountingAccount extends CommonObject
{ {
$this->pcg_type = 'XXXXXX'; $this->pcg_type = 'XXXXXX';
} }
if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
{
$this->pcg_subtype = 'XXXXXX';
}
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
@ -266,7 +254,6 @@ class AccountingAccount extends CommonObject
$sql .= ", entity"; $sql .= ", entity";
$sql .= ", fk_pcg_version"; $sql .= ", fk_pcg_version";
$sql .= ", pcg_type"; $sql .= ", pcg_type";
$sql .= ", pcg_subtype";
$sql .= ", account_number"; $sql .= ", account_number";
$sql .= ", account_parent"; $sql .= ", account_parent";
$sql .= ", label"; $sql .= ", label";
@ -279,7 +266,6 @@ class AccountingAccount extends CommonObject
$sql .= ", " . $conf->entity; $sql .= ", " . $conf->entity;
$sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); $sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
$sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); $sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
$sql .= ", " . (empty($this->pcg_subtype) ? 'NULL' : "'" . $this->db->escape($this->pcg_subtype) . "'");
$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'");
$sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent); $sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent);
$sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'");
@ -341,17 +327,12 @@ class AccountingAccount extends CommonObject
{ {
$this->pcg_type = 'XXXXXX'; $this->pcg_type = 'XXXXXX';
} }
if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
{
$this->pcg_subtype = 'XXXXXX';
}
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
$sql .= " , pcg_subtype = " . ($this->pcg_subtype ? "'" . $this->db->escape($this->pcg_subtype) . "'" : "null");
$sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'";
$sql .= " , account_parent = " . (int) $this->account_parent; $sql .= " , account_parent = " . (int) $this->account_parent;
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''"); $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''");

View File

@ -760,7 +760,7 @@ if (! $error && $action == 'writebookkeeping') {
} }
} }
if (price2num($totaldebit) != price2num($totalcredit)) if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))
{ {
$error++; $error++;
$errorforline++; $errorforline++;

View File

@ -355,7 +355,7 @@ if ($action == 'writebookkeeping') {
} }
// Protection against a bug on line before // Protection against a bug on line before
if (price2num($totaldebit) != price2num($totalcredit)) if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))
{ {
$error++; $error++;
$errorforline++; $errorforline++;

View File

@ -513,7 +513,7 @@ if ($action == 'writebookkeeping') {
} }
// Protection against a bug on lines before // Protection against a bug on lines before
if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit))) if (! $errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
{ {
$error++; $error++;
$errorforline++; $errorforline++;

View File

@ -471,7 +471,7 @@ if ($action == 'writebookkeeping') {
} }
// Protection against a bug on lines before // Protection against a bug on lines before
if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit))) if (! $errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
{ {
$error++; $error++;
$errorforline++; $errorforline++;

View File

@ -17,7 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) if (empty($conf) || !is_object($conf))
{ {
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
@ -29,7 +29,7 @@ $format = $conf->global->ACCOUNTING_EXPORT_FORMAT;
$nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME; $nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME;
$siren = $conf->global->MAIN_INFO_SIREN; $siren = $conf->global->MAIN_INFO_SIREN;
$date_export = "_" . dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $date_export = "_".dol_print_date(dol_now(), '%Y%m%d%H%M%S');
$endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d');
header('Content-Type: text/csv'); header('Content-Type: text/csv');
@ -46,22 +46,22 @@ if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$
$search_date_end = dol_now(); $search_date_end = dol_now();
} }
$datetouseforfilename = $search_date_end; $datetouseforfilename = $search_date_end;
$tmparray=dol_getdate($datetouseforfilename); $tmparray = dol_getdate($datetouseforfilename);
$fiscalmonth=empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START; $fiscalmonth = empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START;
// Define end of month to use // Define end of month to use
if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon']=$fiscalmonth; if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon'] = $fiscalmonth;
else { else {
$tmparray['mon'] = $fiscalmonth; $tmparray['mon'] = $fiscalmonth;
$tmparray['year']++; $tmparray['year']++;
} }
$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard'); $endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
$completefilename = $siren . "FEC" . $endaccountingperiod . ".txt"; $completefilename = $siren."FEC".$endaccountingperiod.".txt";
} }
else else
{ {
$completefilename = ($code?$code . "_":"") . ($prefix?$prefix . "_":"") . $filename . ($nodateexport?"":$date_export) . "." . $format; $completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format;
} }
header('Content-Disposition: attachment;filename=' . $completefilename); header('Content-Disposition: attachment;filename='.$completefilename);

File diff suppressed because it is too large Load Diff

View File

@ -75,7 +75,7 @@ if ($id)
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback); dol_banner_tab($object, 'id', $linkback);
print '<div class="fichecenter">'; print '<div class="fichecenter">';

View File

@ -47,7 +47,7 @@ $search_note = GETPOST('search_note', 'alpha');
$search_account = GETPOST('search_account', 'int'); $search_account = GETPOST('search_account', 'int');
$search_amount = GETPOST('search_amount', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$sall=''; $sall = '';
$date_select = GETPOST("date_select", 'alpha'); $date_select = GETPOST("date_select", 'alpha');
@ -388,16 +388,16 @@ print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.fk_type']['checked'])) print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['d.fk_type']['checked'])) print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder); if (!empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
if (! empty($arrayfields['d.bank']['checked'])) print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['d.bank']['checked'])) print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['c.dateadh']['checked'])) print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); if (!empty($arrayfields['c.dateadh']['checked'])) print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
if (! empty($arrayfields['c.datef']['checked'])) print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); if (!empty($arrayfields['c.datef']['checked'])) print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
if (! empty($arrayfields['d.amount']['checked'])) print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['d.amount']['checked'])) print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';

View File

@ -66,7 +66,7 @@ llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup');
print $langs->trans("ClickToDialDesc")."<br>\n"; print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
print '<br>'; print '<br>';
print '<form method="post" action="clicktodial.php">'; print '<form method="post" action="clicktodial.php">';

View File

@ -414,7 +414,7 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n"; print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name // Name
print '<tr class="oddeven"><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>'; print '<tr class="oddeven"><td class="fieldrequired wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n"; print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
// Address // Address
@ -478,36 +478,36 @@ if (!empty($conf->barcode->enabled)) {
// Logo // Logo
print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), 'png, jpg').'</label></td><td>'; print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), 'png, jpg').'</label></td><td>';
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; print '<div class="centpertent nobordernopadding valignmiddle "><div class="inline-block marginrightonly">';
print '<input type="file" class="flat minwidth200" name="logo" id="logo" accept="image/*">'; print '<input type="file" class="flat minwidth200" name="logo" id="logo" accept="image/*">';
print '</td><td class="nocellnopadd right" valign="middle">'; print '</div><div class="inline-block valignmiddle marginrightonly">';
if (!empty($mysoc->logo_mini)) { if (!empty($mysoc->logo_mini)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>';
if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
print ' &nbsp; '; print '</div><div class="inline-block valignmiddle">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini).'">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini).'">';
} }
} else { } else {
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">'; print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
} }
print '</td></tr></table>'; print '</div>';
print '</td></tr>'; print '</td></tr>';
// Logo (squarred) // Logo (squarred)
print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), 'png, jpg').'</label></td><td>'; print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), 'png, jpg').'</label></td><td>';
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; print '<div class="centpertent nobordernopadding valignmiddle"><div class="inline-block marginrightonly">';
print '<input type="file" class="flat minwidth200" name="logo_squarred" id="logo_squarred" accept="image/*">'; print '<input type="file" class="flat minwidth200" name="logo_squarred" id="logo_squarred" accept="image/*">';
print '</td><td class="nocellnopadd right" valign="middle">'; print '</div><div class="inline-block valignmiddle marginrightonly">';
if (!empty($mysoc->logo_squarred_mini)) { if (!empty($mysoc->logo_squarred_mini)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete")).'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete")).'</a>';
if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) { if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
print ' &nbsp; '; print '</div><div class="inline-block valignmiddle marginrightonly">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini).'">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini).'">';
} }
} else { } else {
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">'; print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
} }
print '</td></tr></table>'; print '</div>';
print '</td></tr>'; print '</td></tr>';
// Note // Note

View File

@ -201,14 +201,14 @@ print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '', $sortfield, $sortorder, '')."\n"; print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '', $sortfield, $sortorder, '')."\n";
print '<td>'.$langs->trans("Value").'</td>'; print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print '<td>'.$langs->trans("Comment").'</td>'; print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center')."\n"; print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
if (! empty($conf->multicompany->enabled) && !$user->entity) if (! empty($conf->multicompany->enabled) && !$user->entity)
{ {
print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center')."\n"; print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
} }
print '<td class="center">'.$langs->trans("Action").'</td>'; print getTitleFieldOfList("Action", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print "</tr>\n"; print "</tr>\n";

View File

@ -87,7 +87,10 @@ if ($action == 'edit')
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
$label = $langs->trans($key); $label = $langs->trans($key);
if ($key == 'DAV_RESTICT_ON_IP') $label = $langs->trans("RESTRICT_ON_IP"); if ($key == 'DAV_RESTICT_ON_IP') {
$label = $langs->trans("RESTRICT_ON_IP");
$label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
}
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR')
@ -124,7 +127,10 @@ else
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
$label = $langs->trans($key); $label = $langs->trans($key);
if ($key == 'DAV_RESTICT_ON_IP') $label = $langs->trans("RESTRICT_ON_IP"); if ($key == 'DAV_RESTICT_ON_IP') {
$label = $langs->trans("RESTRICT_ON_IP");
$label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
}
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR')

View File

@ -231,7 +231,9 @@ if ($action == 'confirm_collect')
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
llxHeader('', 'EmailCollector', ''); $help_url="EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
llxHeader('', 'EmailCollector', $help_url);
// Example : Adding jquery code // Example : Adding jquery code
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
@ -573,6 +575,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'recordevent'=>'RecordEvent'); 'recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
// support hook for add action
$parameters = array( 'arrayoftypes' => $arrayoftypes ) ;
$res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action);
if($res)
$arrayoftypes = $hookmanager->resArray;
else
foreach($hookmanager->resArray as $k=>$desc)
$arrayoftypes[$k]=$desc;
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300'); print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');
print '</td><td>'; print '</td><td>';
print '<input type="text" name="operationparam">'; print '<input type="text" name="operationparam">';

View File

@ -170,10 +170,7 @@ if (empty($reshook))
$form = new Form($db); $form = new Form($db);
$now = dol_now(); $help_url="EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
//$help_url="EN:Module_EmailCollector|FR:Module_EmailCollector_FR|ES:Módulo_EmailCollector";
$help_url = '';
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector"));

View File

@ -58,6 +58,13 @@ if (GETPOST('cancel', 'alpha'))
$action=''; $action='';
} }
// Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff)
$regs = array();
if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) {
if ($regs[1] == 'set') dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity);
else dolibarr_del_const($db, $regs[2], $conf->entity);
}
if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND)) if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND))
{ {
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity);
@ -81,15 +88,15 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update') if ($action == 'update')
{ {
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity);
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); /*$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity); else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/
$val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
@ -141,25 +148,27 @@ if ($action == 'update')
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity);
else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["MAIN_DISABLE_JAVASCRIPT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"], 'chaine', 0, '', 0); // Param for all entities //dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", GETPOST("MAIN_DISABLE_JAVASCRIPT", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", GETPOST("MAIN_BUTTON_HIDE_UNAUTHORIZED", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_START_WEEK", GETPOST("MAIN_START_WEEK", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"], 'chaine', 0, '', 0); // Param for all entities dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", GETPOST("MAIN_DEFAULT_WORKING_DAYS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'int'), 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_SHOW_LOGO", GETPOST("MAIN_SHOW_LOGO", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'none')), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'none')), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST('MAIN_BUGTRACK_ENABLELINK', 'aZ09'), 'chaine', 0, '', $conf->entity);
$varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/'; $varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/';
if ($_FILES[$varforimage]["tmp_name"]) if ($_FILES[$varforimage]["tmp_name"])
{ {
$reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg))
{ {
$original_file=$reg[1]; $original_file=$reg[1];
@ -248,7 +257,7 @@ print '</tr>';
// Multilingual GUI // Multilingual GUI
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print ajax_constantonoff('MAIN_MULTILANGS'); print ajax_constantonoff("MAIN_MULTILANGS", array(), $conf->entity, 0, 0, 1, 0);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -267,7 +276,7 @@ print '</tr>';
// Disable javascript and ajax // Disable javascript and ajax
print '<tr class="oddeven"><td>'.$langs->trans("DisableJavascript").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("DisableJavascript").'</td><td>';
print $form->selectyesno('MAIN_DISABLE_JAVASCRIPT', isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0, 1); print ajax_constantonoff("MAIN_DISABLE_JAVASCRIPT", array(), $conf->entity, 0, 0, 1, 0);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';

View File

@ -25,6 +25,8 @@
* \file htdocs/api/admin/explorer.php * \file htdocs/api/admin/explorer.php
*/ */
use Luracast\Restler\Routes;
require_once '../../main.inc.php'; require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';

View File

@ -96,7 +96,7 @@ llxHeader();
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ApiSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("ApiSetup"), $linkback, 'title_setup');
print $langs->trans("ApiDesc")."<br>\n"; print '<span class="opacitymedium">'.$langs->trans("ApiDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -130,7 +130,9 @@ print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("RESTRICT_API_ON_IP").'</td>'; print '<td>'.$langs->trans("RESTRICT_ON_IP");
print ' '.$langs->trans("Example").': '.$langs->trans("IPListExample");
print '</td>';
print '<td><input type="text" name="API_RESTRICT_ON_IP" value="'.dol_escape_htmltag($conf->global->API_RESTRICT_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 '<td>';
print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></td>'; print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></td>';

View File

@ -80,7 +80,18 @@ 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($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); // Special cases that need to use get_exdir to get real dir of object
// If future, all object should use this to define path of documents.
/*
$tmpreldir = '';
if ($modulepart == 'supplier_invoice') {
$tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier');
}
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */
$relativefile = $original_file;
$check_access = dol_check_secure_access_document($modulepart, $relativefile, $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'];
@ -146,7 +157,18 @@ 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($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); // Special cases that need to use get_exdir to get real dir of object
// If future, all object should use this to define path of documents.
/*
$tmpreldir = '';
if ($modulepart == 'supplier_invoice') {
$tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier');
}
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */
$relativefile = $original_file;
$check_access = dol_check_secure_access_document($modulepart, $relativefile, $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'];
@ -228,7 +250,7 @@ class Documents extends DolibarrApi
/** /**
* Return the list of documents of a dedicated element (from its ID or Ref) * Return the list of documents of a dedicated element (from its ID or Ref)
* *
* @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'shipment', 'project', ...) * @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...)
* @param int $id ID of element * @param int $id ID of element
* @param string $ref Ref of element * @param string $ref Ref of element
* @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size') * @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size')
@ -369,6 +391,24 @@ class Documents extends DolibarrApi
$upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); $upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
} }
elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice')
{
$modulepart = 'supplier_invoice';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401);
}
$object = new FactureFournisseur($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'Invoice not found');
}
$upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref);
}
elseif ($modulepart == 'produit' || $modulepart == 'product') elseif ($modulepart == 'produit' || $modulepart == 'product')
{ {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@ -401,6 +441,22 @@ class Documents extends DolibarrApi
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
} }
elseif ($modulepart == 'expensereport')
{
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
if (!DolibarrApiAccess::$user->rights->expensereport->read && !DolibarrApiAccess::$user->rights->expensereport->read) {
throw new RestException(401);
}
$object = new ExpenseReport($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'Expense report not found');
}
$upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref);
}
else else
{ {
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
@ -432,8 +488,9 @@ class Documents extends DolibarrApi
/** /**
* Upload a file. * Upload a file.
* *
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample for invoice: { "filename": "mynewfile.txt", "modulepart": "invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. * Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }.
* *
* @param string $filename Name of file to create ('FA1705-0123.txt') * @param string $filename Name of file to create ('FA1705-0123.txt')
* @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...) * @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...)
@ -489,6 +546,13 @@ class Documents extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($this->db); $object = new Facture($this->db);
} }
elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice')
{
$modulepart = 'supplier_invoice';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$object = new FactureFournisseur($this->db);
}
elseif ($modulepart == 'project') elseif ($modulepart == 'project')
{ {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -523,6 +587,11 @@ class Documents extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($this->db); $object = new Product($this->db);
} }
elseif ($modulepart == 'expensereport')
{
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$object = new ExpenseReport($this->db);
}
// TODO Implement additional moduleparts // TODO Implement additional moduleparts
else else
{ {
@ -548,6 +617,12 @@ class Documents extends DolibarrApi
throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found."); throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
} }
// Special cases that need to use get_exdir to get real dir of object
// If future, all object should use this to define path of documents.
if ($modulepart == 'supplier_invoice') {
$tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier');
}
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref);
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write'); $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write');
@ -643,7 +718,18 @@ 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($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); // Special cases that need to use get_exdir to get real dir of object
// If future, all object should use this to define path of documents.
/*
$tmpreldir = '';
if ($modulepart == 'supplier_invoice') {
$tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier');
}
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */
$relativefile = $original_file;
$check_access = dol_check_secure_access_document($modulepart, $relativefile, $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'];

View File

@ -554,6 +554,70 @@ class Setup extends DolibarrApi
return $list; return $list;
} }
/**
* Get the list of Expense Report types.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $module To filter on module
* @param int $active Event's type is active or not {@min 0} {@max 1}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return array List of expense report types
*
* @url GET dictionary/expensereport_types
*
* @throws RestException
*/
public function getListOfExpenseReportsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '')
{
$list = array();
$sql = "SELECT id, code, label, accountancy_code, active, module, position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t";
$sql .= " WHERE t.active = ".$active;
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of expense report types : '.$this->db->lasterror());
}
return $list;
}
/** /**
* Get the list of contacts types. * Get the list of contacts types.
* *

View File

@ -278,6 +278,7 @@ dol_htmloutput_errors($mesg);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="mode" value="label">'; print '<input type="hidden" name="mode" value="label">';
print '<input type="hidden" name="action" value="builddoc">'; print '<input type="hidden" name="action" value="builddoc">';
print '<input type="hidden" name="token" value="'.newtoken().'">';
print '<div class="tagtable">'; print '<div class="tagtable">';

View File

@ -28,9 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin","other","blockedlog")); $langs->loadLangs(array("admin", "other", "blockedlog"));
if (! $user->admin || empty($conf->blockedlog->enabled)) accessforbidden(); if (!$user->admin || empty($conf->blockedlog->enabled)) accessforbidden();
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -77,22 +77,22 @@ if (preg_match('/del_(.*)/', $action, $reg))
* View * View
*/ */
$form=new Form($db); $form = new Form($db);
$block_static = new BlockedLog($db); $block_static = new BlockedLog($db);
llxHeader('', $langs->trans("BlockedLogSetup")); llxHeader('', $langs->trans("BlockedLogSetup"));
$linkback=''; $linkback = '';
if (GETPOST('withtab', 'alpha')) if (GETPOST('withtab', 'alpha'))
{ {
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
} }
print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'), $linkback); print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'), $linkback);
if (GETPOST('withtab', 'alpha')) if (GETPOST('withtab', 'alpha'))
{ {
$head=blockedlogadmin_prepare_head(); $head = blockedlogadmin_prepare_head();
dol_fiche_head($head, 'blockedlog', '', -1); dol_fiche_head($head, 'blockedlog', '', -1);
} }
@ -135,16 +135,16 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">'; print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite"; $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
$sql.= " FROM ".MAIN_DB_PREFIX."c_country"; $sql .= " FROM ".MAIN_DB_PREFIX."c_country";
$sql.= " WHERE active > 0"; $sql .= " WHERE active > 0";
$countryArray=array(); $countryArray = array();
$resql=$db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
while ($obj = $db->fetch_object($resql)) while ($obj = $db->fetch_object($resql))
{ {
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:'')); $countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
} }
} }
@ -160,8 +160,8 @@ print '</td>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="titlefield">'; print '<td class="titlefield">';
print $langs->trans("ListOfTrackedEvents").'</td><td>'; print $langs->trans("ListOfTrackedEvents").'</td><td>';
$arrayoftrackedevents=$block_static->trackedevents; $arrayoftrackedevents = $block_static->trackedevents;
foreach($arrayoftrackedevents as $key => $val) foreach ($arrayoftrackedevents as $key => $val)
{ {
print $key.' - '.$langs->trans($val).'<br>'; print $key.' - '.$langs->trans($val).'<br>';
} }

View File

@ -520,7 +520,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<table class="border centpercent tableforfield">'."\n"; print '<table class="border centpercent tableforfield">'."\n";
// Common attributes // Common attributes
$keyforbreak = 'efficiency'; $keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
// Other attributes // Other attributes

View File

@ -95,7 +95,7 @@ class BOM extends CommonObject
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'),
'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'),
'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), //'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLossForProductProduced'),
'duration' => array('type'=>'duration', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), 'duration' => array('type'=>'duration', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>102), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>102),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-2, 'position'=>161, 'notnull'=>-1,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-2, 'position'=>161, 'notnull'=>-1,),
@ -561,7 +561,7 @@ class BOM extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num; $this->newref = dol_sanitizeFileName($num);
// Validate // Validate
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
@ -1056,7 +1056,7 @@ class BOMLine extends CommonObjectLine
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
//'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), 'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'),
'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
); );

View File

@ -98,11 +98,11 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) if (!empty($conf->global->ENTREPOT_EXTRA_STATUS))
{ {
// hide products in closed warehouse, but show products for internal transfer // hide products in closed warehouse, but show products for internal transfer
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
} }
else else
{ {
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
} }
echo '</span>'; echo '</span>';
@ -128,11 +128,10 @@ $coldisplay++;
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '').'">'; print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '').'">';
print '</td>'; print '</td>';
//$coldisplay++; $coldisplay++;
//print '<td class="bordertop nobottom nowrap linecollost right">'; print '<td class="bordertop nobottom nowrap linecollost right">';
//print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">'; print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">';
//print '</td>'; print '</td>';
$coldisplay += $colspan; $coldisplay += $colspan;
print '<td class="bordertop nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">'; print '<td class="bordertop nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
@ -141,7 +140,7 @@ print '</td>';
print '</tr>'; print '</tr>';
if (is_object($objectline)) { if (is_object($objectline)) {
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1);
} }
?> ?>

View File

@ -124,9 +124,9 @@ $coldisplay++;
print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOSTISSET('disablestockchange')?(GETPOST("disable_stock_change", 'int')?' checked="checked"':''):($line->disable_stock_change?' checked="checked"':'')).'">'; print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOSTISSET('disablestockchange')?(GETPOST("disable_stock_change", 'int')?' checked="checked"':''):($line->disable_stock_change?' checked="checked"':'')).'">';
print '</td>'; print '</td>';
//$coldisplay++; $coldisplay++;
//print '<td class="nobottom nowrap linecollost right">'; print '<td class="nobottom nowrap linecollost right">';
//print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>'; print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>';
$coldisplay+=$colspan; $coldisplay+=$colspan;
print '<td class="nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">'; print '<td class="nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
@ -138,7 +138,7 @@ print '</td>';
print '</tr>'; print '</tr>';
if (is_object($objectline)) { if (is_object($objectline)) {
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1);
} }
print "<!-- END PHP TEMPLATE objectline_edit.tpl.php -->\n"; print "<!-- END PHP TEMPLATE objectline_edit.tpl.php -->\n";

View File

@ -66,7 +66,7 @@ print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('QtyFro
print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>'; print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
// Efficiency // Efficiency
//print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('XXX')).'</td>'; print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
print '<td class="linecoledit"></td>'; // No width to allow autodim print '<td class="linecoledit"></td>'; // No width to allow autodim

View File

@ -98,10 +98,10 @@ $coldisplay++;
echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price
print '</td>'; print '</td>';
//print '<td class="linecolqty nowrap right">'; print '<td class="linecolefficiency nowrap right">';
//$coldisplay++; $coldisplay++;
//echo $line->efficiency; echo $line->efficiency;
//print '</td>'; print '</td>';
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) {
print '<td class="linecoledit center">'; print '<td class="linecoledit center">';
@ -156,7 +156,7 @@ print '</tr>';
//Line extrafield //Line extrafield
if (!empty($extrafields)) if (!empty($extrafields))
{ {
print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1);
} }
print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n"; print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";

View File

@ -35,62 +35,62 @@ function printDropdownBookmarksList()
$langs->load("bookmarks"); $langs->load("bookmarks");
$url= $_SERVER["PHP_SELF"]; $url = $_SERVER["PHP_SELF"];
if (! empty($_SERVER["QUERY_STRING"])) if (!empty($_SERVER["QUERY_STRING"]))
{ {
$url.=(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''); $url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '');
} }
else else
{ {
global $sortfield,$sortorder; global $sortfield, $sortorder;
$tmpurl=''; $tmpurl = '';
// No urlencode, all param $url will be urlencoded later // No urlencode, all param $url will be urlencoded later
if ($sortfield) $tmpurl.=($tmpurl?'&':'').'sortfield='.$sortfield; if ($sortfield) $tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield;
if ($sortorder) $tmpurl.=($tmpurl?'&':'').'sortorder='.$sortorder; if ($sortorder) $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder;
if (is_array($_POST)) if (is_array($_POST))
{ {
foreach($_POST as $key => $val) foreach ($_POST as $key => $val)
{ {
if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val; if (preg_match('/^search_/', $key) && $val != '') $tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val;
} }
} }
$url.=($tmpurl?'?'.$tmpurl:''); $url .= ($tmpurl ? '?'.$tmpurl : '');
} }
$searchForm = '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n"; $searchForm = '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n";
$searchForm.= '<form id="top-menu-action-bookmark" name="actionbookmark" method="POST" action="" onsubmit="return false" >'; $searchForm .= '<form id="top-menu-action-bookmark" name="actionbookmark" method="POST" action="" onsubmit="return false" >';
$searchForm.= '<input name="bookmark" id="top-bookmark-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Bookmarks').'" autocomplete="off" >'; $searchForm .= '<input name="bookmark" id="top-bookmark-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Bookmarks').'" autocomplete="off" >';
$searchForm.= '</form>'; $searchForm .= '</form>';
// Url to list bookmark // Url to list bookmark
$listbtn = '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.DOL_URL_ROOT.'/bookmarks/list.php" >'; $listbtn = '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.DOL_URL_ROOT.'/bookmarks/list.php" >';
$listbtn.= '<span class="fa fa-list"></span> '.$langs->trans('Bookmarks').'</a>'; $listbtn .= '<span class="fa fa-list paddingright"></span>'.$langs->trans('Bookmarks').'</a>';
// Url to go on create new bookmark page // Url to go on create new bookmark page
$newbtn = ''; $newbtn = '';
if (! empty($user->rights->bookmark->creer)) if (!empty($user->rights->bookmark->creer))
{ {
//$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url); //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url);
$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
$newbtn.= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >'; $newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >';
$newbtn.= img_picto('', 'bookmark').' '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>'; $newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>';
} }
$bookmarkList='<div id="dropdown-bookmarks-list" >'; $bookmarkList = '<div id="dropdown-bookmarks-list" >';
// Menu with list of bookmarks // Menu with list of bookmarks
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; $sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
$sql.= " AND entity IN (".getEntity('bookmarks').")"; $sql .= " AND entity IN (".getEntity('bookmarks').")";
$sql.= " ORDER BY position"; $sql .= " ORDER BY position";
if ($resql = $db->query($sql) ) if ($resql = $db->query($sql))
{ {
$i=0; $i = 0;
while (($conf->global->BOOKMARKS_SHOW_IN_MENU == 0 || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) while (($conf->global->BOOKMARKS_SHOW_IN_MENU == 0 || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql))
{ {
$bookmarkList.='<a class="dropdown-item bookmark-item" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1?' target="_blank"':'').' href="'.dol_escape_htmltag($obj->url).'" >'; $bookmarkList .= '<a class="dropdown-item bookmark-item" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >';
$bookmarkList.= dol_escape_htmltag($obj->title); $bookmarkList .= dol_escape_htmltag($obj->title);
$bookmarkList.='</a>'; $bookmarkList .= '</a>';
$i++; $i++;
} }
} }
@ -98,23 +98,23 @@ function printDropdownBookmarksList()
{ {
dol_print_error($db); dol_print_error($db);
} }
$bookmarkList.='</div>'; $bookmarkList .= '</div>';
$html = ' $html = '
<!-- search input --> <!-- search input -->
<div class="dropdown-header bookmark-header"> <div class="dropdown-header bookmark-header">
' . $searchForm . ' ' . $searchForm.'
</div> </div>
'; ';
$html.= ' $html .= '
<!-- Menu Body --> <!-- Menu Body -->
<div class="bookmark-body dropdown-body"> <div class="bookmark-body dropdown-body">
'.$bookmarkList.' '.$bookmarkList.'
</div> </div>
'; ';
$html.= ' $html .= '
<!-- Menu Footer--> <!-- Menu Footer-->
<div class="bookmark-footer"> <div class="bookmark-footer">
'.$newbtn.$listbtn.' '.$newbtn.$listbtn.'

View File

@ -167,8 +167,9 @@ class Categorie extends CommonObject
'member' => 'adherent', 'member' => 'adherent',
'contact' => 'socpeople', 'contact' => 'socpeople',
'user' => 'user', 'user' => 'user',
'account' => 'bank_account', 'account' => 'bank_account', // old for bank account
'project' => 'projet', 'bank_account' => 'bank_account',
'project' => 'projet',
'warehouse'=> 'entrepot', 'warehouse'=> 'entrepot',
'actioncomm' => 'actioncomm', 'actioncomm' => 'actioncomm',
); );
@ -774,7 +775,7 @@ class Categorie extends CommonObject
/** /**
* Return list of fetched instance of elements having this category * Return list of fetched instance of elements having this category
* *
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member', ...)
* @param int $onlyids Return only ids of objects (consume less memory) * @param int $onlyids Return only ids of objects (consume less memory)
* @param int $limit Limit * @param int $limit Limit
* @param int $offset Offset * @param int $offset Offset
@ -1957,4 +1958,56 @@ class Categorie extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1);
} }
/**
* Return the addtional SQL JOIN query for filtering a list by a category
*
* @param string $type The category type (e.g Categorie::TYPE_WAREHOUSE)
* @param string $rowIdName The name of the row id inside the whole sql query (e.g. "e.rowid")
* @return string A additional SQL JOIN query
*/
public static function getFilterJoinQuery($type, $rowIdName)
{
return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp"
. " ON ".$rowIdName." = cp.fk_".$type;
}
/**
* Return the addtional SQL SELECT query for filtering a list by a category
*
* @param string $type The category type (e.g Categorie::TYPE_WAREHOUSE)
* @param string $rowIdName The name of the row id inside the whole sql query (e.g. "e.rowid")
* @param Array $searchList A list with the selected categories
* @return string A additional SQL SELECT query
*/
public static function getFilterSelectQuery($type, $rowIdName, $searchList)
{
if (empty($searchList) && !is_array($searchList))
{
return "";
}
foreach ($searchList as $searchCategory)
{
if (intval($searchCategory) == -2)
{
$searchCategorySqlList[] = " cp.fk_categorie IS NULL";
}
elseif (intval($searchCategory) > 0)
{
$searchCategorySqlList[] = " ".$rowIdName
." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type
." WHERE fk_categorie = ".$searchCategory.")";
}
}
if (!empty($searchCategorySqlList))
{
return " AND (".implode(' AND ', $searchCategorySqlList).")";
}
else
{
return "";
}
}
} }

View File

@ -182,23 +182,13 @@ foreach ($fulltree as $key => $val)
$li = $categstatic->getNomUrl(1, '', 60); $li = $categstatic->getNomUrl(1, '', 60);
$desc = dol_htmlcleanlastbr($val['description']); $desc = dol_htmlcleanlastbr($val['description']);
$counter = '';
if($conf->global->CATEGORY_SHOW_COUNTS) if($conf->global->CATEGORY_SHOW_COUNTS)
{ {
// we need only a count of the elements, so it is enough to consume only the id's from the database // we need only a count of the elements, so it is enough to consume only the id's from the database
if ($type == Categorie::TYPE_PRODUCT) $elements = $categstatic->getObjectsInCateg("product", 1); $elements = $categstatic->getObjectsInCateg($type, 1);
if ($type == Categorie::TYPE_SUPPLIER) $elements = $categstatic->getObjectsInCateg("supplier", 1); $counter = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>";
if ($type == Categorie::TYPE_CUSTOMER) $elements = $categstatic->getObjectsInCateg("customer", 1);
if ($type == Categorie::TYPE_MEMBER) $elements = $categstatic->getObjectsInCateg("member", 1);
if ($type == Categorie::TYPE_CONTACT) $elements = $categstatic->getObjectsInCateg("contact", 1);
if ($type == Categorie::TYPE_ACCOUNT) $elements = $categstatic->getObjectsInCateg("account", 1);
if ($type == Categorie::TYPE_PROJECT) $elements = $categstatic->getObjectsInCateg("project", 1);
if ($type == Categorie::TYPE_USER) $elements = $categstatic->getObjectsInCateg("user", 1);
$counter = "<td class='left' width='40px;'>".count($elements)."</td>";
}
else
{
$counter = "";
} }
$data[] = array( $data[] = array(

View File

@ -666,7 +666,7 @@ if ($object->id > 0)
$now = dol_now(); $now = dol_now();
/* /*
* Last proposals * Latest proposals
*/ */
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if (!empty($conf->propal->enabled) && $user->rights->propal->lire)
{ {
@ -738,7 +738,7 @@ if ($object->id > 0)
} }
/* /*
* Last orders * Latest orders
*/ */
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
{ {
@ -824,7 +824,7 @@ if ($object->id > 0)
} }
/* /*
* Last shipments * Latest shipments
*/ */
if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire)
{ {
@ -897,7 +897,7 @@ if ($object->id > 0)
} }
/* /*
* Last linked contracts * Latest linked contracts
*/ */
if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
{ {
@ -967,7 +967,7 @@ if ($object->id > 0)
} }
/* /*
* Last interventions * Latest interventions
*/ */
if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
{ {
@ -1028,7 +1028,7 @@ if ($object->id > 0)
} }
/* /*
* Last invoices templates * Latest invoices templates
*/ */
if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{ {
@ -1063,7 +1063,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">'; print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> /* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* *
* 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
@ -64,11 +65,66 @@ class Proposals extends DolibarrApi
*/ */
public function get($id, $contact_list = 1) public function get($id, $contact_list = 1)
{ {
return $this->_fetch($id, '', '', '', $contact_list);
}
/**
* Get properties of an proposal object by ref
*
* Return an array with proposal informations
*
* @param string $ref Ref of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @url GET ref/{ref}
*
* @throws RestException
*/
public function getByRef($ref, $contact_list = 1)
{
return $this->_fetch('', $ref, '', '', $contact_list);
}
/**
* Get properties of an proposal object by ref_ext
*
* Return an array with proposal informations
*
* @param string $ref_ext External reference of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @url GET ref_ext/{ref_ext}
*
* @throws RestException
*/
public function getByRefExt($ref_ext, $contact_list = 1)
{
return $this->_fetch('', '', $ref_ext, '', $contact_list);
}
/**
* Get properties of an proposal object
*
* Return an array with proposal informations
*
* @param int $id ID of order
* @param string $ref Ref of object
* @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other objec
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @throws RestException
*/
private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1)
{
if(! DolibarrApiAccess::$user->rights->propal->lire) { if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id, $ref, $ref_ext, $ref_int);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }

View File

@ -1803,7 +1803,7 @@ class Propal extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num; $this->newref = dol_sanitizeFileName($num);
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " SET ref = '".$this->db->escape($num)."',";

View File

@ -69,6 +69,11 @@ $search_societe = GETPOST('search_societe', 'alpha');
$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
$search_login = GETPOST('search_login', 'alpha'); $search_login = GETPOST('search_login', 'alpha');
$search_product_category = GETPOST('search_product_category', 'int'); $search_product_category = GETPOST('search_product_category', 'int');
$search_town = GETPOST('search_town', 'alpha'); $search_town = GETPOST('search_town', 'alpha');
@ -162,8 +167,15 @@ $arrayfields = array(
'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT), 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT), 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
'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),
@ -209,6 +221,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_montant_ht = ''; $search_montant_ht = '';
$search_montant_vat = ''; $search_montant_vat = '';
$search_montant_ttc = ''; $search_montant_ttc = '';
$search_multicurrency_code = '';
$search_multicurrency_tx = '';
$search_multicurrency_montant_ht = '';
$search_multicurrency_montant_vat = '';
$search_multicurrency_montant_ttc = '';
$search_login = ''; $search_login = '';
$search_product_category = ''; $search_product_category = '';
$search_town = ''; $search_town = '';
@ -269,6 +286,7 @@ $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.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva as multicurrency_total_vat, p.multicurrency_total_ttc,';
$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql .= ' p.note_public, p.note_private,'; $sql .= ' p.note_public, p.note_private,';
$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,";
@ -326,6 +344,11 @@ if ($search_login) $sql .= natural_search("u.login", $search_login);
if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1);
if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"';
if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
if ($search_multicurrency_montant_vat != '') $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('p.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
if ($sall) { if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall); $sql .= natural_search(array_keys($fieldstosearchall), $sall);
} }
@ -428,6 +451,11 @@ if ($resql)
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht); if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht);
if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_login) $param .= '&search_login='.urlencode($search_login);
if ($search_town) $param .= '&search_town='.urlencode($search_town); if ($search_town) $param .= '&search_town='.urlencode($search_town);
if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
@ -677,6 +705,53 @@ if ($resql)
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['p.multicurrency_code']['checked']))
{
// Currency
print '<td class="liste_titre">';
print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
print '</td>';
}
if (!empty($arrayfields['p.multicurrency_tx']['checked']))
{
// Currency rate
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
print '</td>';
}
if (!empty($arrayfields['p.multicurrency_total_ht']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
print '</td>';
}
if (!empty($arrayfields['p.multicurrency_total_vat']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
print '</td>';
}
if (!empty($arrayfields['p.multicurrency_total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
print '</td>';
}
if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked']))
{
// Amount invoiced
print '<td class="liste_titre right">';
print '</td>';
}
if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked']))
{
// Amount invoiced
print '<td class="liste_titre right">';
print '</td>';
}
if (!empty($arrayfields['u.login']['checked'])) if (!empty($arrayfields['u.login']['checked']))
{ {
// Author // Author
@ -750,6 +825,13 @@ if ($resql)
if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
// Extra fields // Extra fields
@ -790,6 +872,29 @@ if ($resql)
$projectstatic->ref = $obj->project_ref; $projectstatic->ref = $obj->project_ref;
$projectstatic->title = $obj->project_label; $projectstatic->title = $obj->project_label;
$totalInvoicedHT = 0;
$totalInvoicedTTC = 0;
$multicurrency_totalInvoicedHT = 0;
$multicurrency_totalInvoicedTTC = 0;
$TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid);
if (!empty($TInvoiceData))
{
foreach ($TInvoiceData as $invoiceData)
{
$invoice = new Facture($db);
$invoice->fetch($invoiceData->facid);
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
$totalInvoicedHT += $invoice->total_ht;
$totalInvoicedTTC += $invoice->total_ttc;
$multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht;
$multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc;
}
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (!empty($arrayfields['p.ref']['checked'])) if (!empty($arrayfields['p.ref']['checked']))
@ -975,46 +1080,66 @@ if ($resql)
$totalarray['val']['p.total_ttc'] += $obj->total_ttc; $totalarray['val']['p.total_ttc'] += $obj->total_ttc;
} }
// Amount invoiced // Amount invoiced
if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { if (!empty($arrayfields['p.total_ht_invoiced']['checked']))
$totalInvoiced = 0; {
$p = new Propal($db); print '<td class="nowrap right">'.price($totalInvoicedHT)."</td>\n";
$TInvoiceData = $p->InvoiceArrayList($obj->rowid);
if (!empty($TInvoiceData)) {
foreach ($TInvoiceData as $invoiceData) {
$invoice = new Facture($db);
$invoice->fetch($invoiceData->facid);
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
$totalInvoiced += $invoice->total_ht;
}
}
print '<td class="nowrap right">'.price($totalInvoiced)."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced';
$totalarray['val']['p.total_ht_invoiced'] += $obj->total_ht_invoiced; $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT;
} }
// Amount invoiced // Amount invoiced
if (!empty($arrayfields['p.total_invoiced']['checked'])) { if (!empty($arrayfields['p.total_invoiced']['checked']))
$totalInvoiced = 0; {
$p = new Propal($db); print '<td class="nowrap right">'.price($totalInvoicedTTC)."</td>\n";
$TInvoiceData = $p->InvoiceArrayList($obj->rowid);
if (!empty($TInvoiceData)) {
foreach ($TInvoiceData as $invoiceData) {
$invoice = new Facture($db);
$invoice->fetch($invoiceData->facid);
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
$totalInvoiced += $invoice->total_ttc;
}
}
print '<td class="nowrap right">'.price($totalInvoiced)."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced';
$totalarray['val']['p.total_invoiced'] += $obj->total_invoiced; $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC;
}
// Currency
if (!empty($arrayfields['p.multicurrency_code']['checked']))
{
print '<td class="nowrap">'.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Currency rate
if (!empty($arrayfields['p.multicurrency_tx']['checked']))
{
print '<td class="nowrap">';
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount HT
if (!empty($arrayfields['p.multicurrency_total_ht']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount VAT
if (!empty($arrayfields['p.multicurrency_total_vat']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount TTC
if (!empty($arrayfields['p.multicurrency_total_ttc']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount invoiced
if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked']))
{
print '<td class="nowrap right">'.price($multicurrency_totalInvoicedHT)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount invoiced
if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked']))
{
print '<td class="nowrap right">'.price($multicurrency_totalInvoicedTTC)."</td>\n";
if (!$i) $totalarray['nbfield']++;
} }
$userstatic->id = $obj->fk_user_author; $userstatic->id = $obj->fk_user_author;

View File

@ -111,6 +111,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
$newdiscount1->description = $discount->description.' (1)'; $newdiscount1->description = $discount->description.' (1)';
$newdiscount2->description = $discount->description.' (2)'; $newdiscount2->description = $discount->description.' (2)';
} }
$newdiscount1->fk_user = $discount->fk_user; $newdiscount1->fk_user = $discount->fk_user;
$newdiscount2->fk_user = $discount->fk_user; $newdiscount2->fk_user = $discount->fk_user;
$newdiscount1->fk_soc = $discount->fk_soc; $newdiscount1->fk_soc = $discount->fk_soc;
@ -121,7 +122,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
$newdiscount2->datec = $discount->datec; $newdiscount2->datec = $discount->datec;
$newdiscount1->tva_tx = $discount->tva_tx; $newdiscount1->tva_tx = $discount->tva_tx;
$newdiscount2->tva_tx = $discount->tva_tx; $newdiscount2->tva_tx = $discount->tva_tx;
$newdiscount1->amount_ttc = $_POST["amount_ttc_1"]; $newdiscount1->amount_ttc = $amount_ttc_1;
$newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc); $newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc);
$newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); $newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT');
$newdiscount2->amount_ht = price2num($newdiscount2->amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT'); $newdiscount2->amount_ht = price2num($newdiscount2->amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT');

View File

@ -93,25 +93,29 @@ $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
// 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'));
$usercanread = $user->rights->commande->lire; $usercanread = $user->rights->commande->lire;
$usercancreate = $user->rights->commande->creer; $usercancreate = $user->rights->commande->creer;
$usercanclose = $user->rights->commande->cloturer; $usercanclose = $user->rights->commande->cloturer;
$usercandelete = $user->rights->commande->supprimer; $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))); $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))); $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); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send);
$usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; $usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer;
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
if (!empty($conf->expedition->enabled) && $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER = 1){
if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse;
}
/* /*
* Actions * Actions
@ -1594,25 +1598,25 @@ if ($action == 'create' && $usercancreate)
$note_public = $object->getDefaultCreateValueFor('note_public'); $note_public = $object->getDefaultCreateValueFor('note_public');
} }
print '<form name="crea_commande" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; print '<form name="crea_commande" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
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="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n"; print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
print '<input type="hidden" name="remise_percent" value="' . $soc->remise_percent . '">'; print '<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.'">';
print '<input type="hidden" name="origin" value="' . $origin . '">'; print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="' . $originid . '">'; print '<input type="hidden" name="originid" value="'.$originid.'">';
if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx . '">'; if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">';
dol_fiche_head(''); dol_fiche_head('');
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Reference // Reference
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td>' . $langs->trans("Draft") . '</td></tr>'; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>';
// Reference client // Reference client
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td>'; print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && ! empty($origin) && ! empty($originid)) if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid))
print '<input type="text" name="ref_client" value="'.$ref_client.'"></td>'; print '<input type="text" name="ref_client" value="'.$ref_client.'"></td>';
else else
print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>'; print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>';
@ -2556,7 +2560,7 @@ if ($action == 'create' && $usercancreate)
} }
// Valid // Valid
if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || ! empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a>';
} }

View File

@ -384,7 +384,7 @@ class Commande extends CommonOrder
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num; $this->newref = dol_sanitizeFileName($num);
// Validate // Validate
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";

View File

@ -74,8 +74,14 @@ $socid = GETPOST('socid', 'int');
$search_user = GETPOST('search_user', 'int'); $search_user = GETPOST('search_user', 'int');
$search_sale = GETPOST('search_sale', 'int'); $search_sale = GETPOST('search_sale', 'int');
$search_total_ht = GETPOST('search_total_ht', 'alpha'); $search_total_ht = GETPOST('search_total_ht', 'alpha');
$search_total_vat = GETPOST('search_total_vat', 'alpha');
$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha');
$search_warehouse = GETPOST('search_warehouse', 'int'); $search_warehouse = GETPOST('search_warehouse', 'int');
$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
$search_login = GETPOST('search_login', 'alpha'); $search_login = GETPOST('search_login', 'alpha');
$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
@ -142,6 +148,11 @@ $arrayfields = array(
'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
'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),
@ -198,6 +209,11 @@ if (empty($reshook))
$search_total_ht = ''; $search_total_ht = '';
$search_total_vat = ''; $search_total_vat = '';
$search_total_ttc = ''; $search_total_ttc = '';
$search_multicurrency_code = '';
$search_multicurrency_tx = '';
$search_multicurrency_montant_ht = '';
$search_multicurrency_montant_vat = '';
$search_multicurrency_montant_ttc = '';
$search_login = ''; $search_login = '';
$search_dateorder_start = ''; $search_dateorder_start = '';
$search_dateorder_end = ''; $search_dateorder_end = '';
@ -251,6 +267,7 @@ $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.
$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,";
$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; $sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
$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, c.date_cloture as date_cloture,'; $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,";
@ -315,26 +332,32 @@ if ($viewstatut <> '')
} }
} }
if ($search_dateorder_start) $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; if ($search_dateorder_start) $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'";
if ($search_dateorder_end) $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; if ($search_dateorder_end) $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'";
if ($search_datedelivery_start) $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; if ($search_datedelivery_start) $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
if ($search_datedelivery_end) $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; if ($search_datedelivery_end) $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
if ($search_town) $sql .= natural_search('s.town', $search_town); if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip); if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1);
if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1);
if ($search_warehouse != '') $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_warehouse != '') $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"';
if ($search_project != '') $sql .= natural_search("p.title", $search_project); if ($search_multicurrency_tx != '') $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_multicurrency_montant_vat != '') $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
if ($search_login) $sql .= natural_search("u.login", $search_login);
if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref);
if ($search_project != '') $sql .= natural_search("p.title", $search_project);
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -428,6 +451,11 @@ if ($resql)
if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc);
if ($search_warehouse != '') $param .= '&search_warehouse='.urlencode($search_warehouse); if ($search_warehouse != '') $param .= '&search_warehouse='.urlencode($search_warehouse);
if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_login) $param .= '&search_login='.urlencode($search_login);
if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
if ($search_town != '') $param .= '&search_town='.urlencode($search_town); if ($search_town != '') $param .= '&search_town='.urlencode($search_town);
if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip);
@ -708,6 +736,41 @@ if ($resql)
print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">'; print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['c.multicurrency_code']['checked']))
{
// Currency
print '<td class="liste_titre">';
print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
print '</td>';
}
if (!empty($arrayfields['c.multicurrency_tx']['checked']))
{
// Currency rate
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
print '</td>';
}
if (!empty($arrayfields['c.multicurrency_total_ht']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
print '</td>';
}
if (!empty($arrayfields['c.multicurrency_total_vat']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
print '</td>';
}
if (!empty($arrayfields['c.multicurrency_total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
print '</td>';
}
if (!empty($arrayfields['u.login']['checked'])) if (!empty($arrayfields['u.login']['checked']))
{ {
// Author // Author
@ -786,6 +849,11 @@ if ($resql)
if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['c.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
// Extra fields // Extra fields
@ -1108,6 +1176,40 @@ if ($resql)
$totalarray['val']['c.total_ttc'] += $obj->total_ttc; $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
} }
// Currency
if (!empty($arrayfields['c.multicurrency_code']['checked']))
{
print '<td class="nowrap">'.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Currency rate
if (!empty($arrayfields['c.multicurrency_tx']['checked']))
{
print '<td class="nowrap">';
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount HT
if (!empty($arrayfields['c.multicurrency_total_ht']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount VAT
if (!empty($arrayfields['c.multicurrency_total_vat']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount TTC
if (!empty($arrayfields['c.multicurrency_total_ttc']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
$userstatic->id = $obj->fk_user_author; $userstatic->id = $obj->fk_user_author;
$userstatic->login = $obj->login; $userstatic->login = $obj->login;

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta")); $langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips"));
$date_start = GETPOST('date_start', 'alpha'); $date_start = GETPOST('date_start', 'alpha');
$date_startDay = GETPOST('date_startday', 'int'); $date_startDay = GETPOST('date_startday', 'int');
@ -66,7 +66,14 @@ if (!$sortorder) $sortorder = "DESC";
$arrayfields = array( $arrayfields = array(
'type'=>array('label'=>"Type", 'checked'=>1), 'type'=>array('label'=>"Type", 'checked'=>1),
'date'=>array('label'=>"Date", 'checked'=>1), 'date'=>array('label'=>"Date", 'checked'=>1),
//... 'date_due'=>array('label'=>"DateDue", 'checked'=>1),
'ref'=>array('label'=>"Ref", 'checked'=>1),
'documents'=>array('label'=>"Documents", 'checked'=>1),
'paid'=>array('label'=>"Paid", 'checked'=>1),
'total_ht'=>array('label'=>"TotalHT", 'checked'=>1),
'total_ttc'=>array('label'=>"TotalTTC", 'checked'=>1),
'total_vat'=>array('label'=>"TotalVAT", 'checked'=>1),
//...
); );
// Security check // Security check
@ -85,7 +92,7 @@ if (!empty($conf->multicompany->enabled) && is_object($mc)) {
$entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity)); $entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity));
if (!empty($conf->multicompany->enabled) && is_object($mc)) { if (!empty($conf->multicompany->enabled) && is_object($mc)) {
if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
$entity = '0,'.join(',', array_keys($arrayofentities)); $entity = '0,'.join(',', array_keys($arrayofentities));
} }
} }
@ -120,190 +127,213 @@ if (($action == "searchfiles" || $action == "dl")) {
if (!$error) if (!$error)
{ {
$sql = '';
$wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
// Customer invoices // Customer invoices
$sql = "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; if (GETPOST('selectinvoices')) {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; if (! empty($sql)) $sql .= " UNION ALL";
$sql .= " WHERE datef between ".$wheretail; $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; $sql .= " WHERE datef between ".$wheretail;
$sql .= " UNION ALL"; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT;
}
// Vendor invoices // Vendor invoices
$sql .= " SELECT t.rowid as id, t.entity, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; if (GETPOST('selectsupplierinvoices')) {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; if (! empty($sql)) $sql .= " UNION ALL";
$sql .= " WHERE datef between ".$wheretail; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; $sql .= " WHERE datef between ".$wheretail;
$sql .= " UNION ALL"; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
}
// Expense reports // Expense reports
$sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; if (GETPOST('selectexpensereports')) {
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; if (! empty($sql)) $sql .= " UNION ALL";
$sql .= " WHERE date_fin between ".$wheretail; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; $sql .= " WHERE date_fin between ".$wheretail;
$sql .= " UNION ALL"; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
}
// Donations // Donations
$sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; if (GETPOST('selectdonations')) {
$sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; if (! empty($sql)) $sql .= " UNION ALL";
$sql .= " WHERE datedon between ".$wheretail; $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
$sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; $sql .= " WHERE datedon between ".$wheretail;
$sql .= " UNION ALL"; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT;
}
// Paiements of salaries // Paiements of salaries
$sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; if (GETPOST('selectpaymentsofsalaries')) {
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; if (! empty($sql)) $sql .= " UNION ALL";
$sql .= " WHERE datep between ".$wheretail; $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; $sql .= " WHERE datep between ".$wheretail;
$sql .= " UNION ALL"; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
}
// Social contributions // Social contributions
$sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; if (GETPOST('selectsocialcontributions')) {
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; if (! empty($sql)) $sql .= " UNION ALL";
$sql .= " WHERE date_creation between ".$wheretail; $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_creation as date, t.date_ech as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum";
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
//$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; $sql .= " WHERE date_creation between ".$wheretail;
$sql .= $db->order($sortfield, $sortorder); $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
//print $sql; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
}
$resd = $db->query($sql); if ($sql) {
$files = array(); $sql .= $db->order($sortfield, $sortorder);
$link = ''; //print $sql;
if ($resd) $resd = $db->query($sql);
{ $files = array();
$numd = $db->num_rows($resd); $link = '';
$tmpinvoice = new Facture($db); if ($resd)
$tmpinvoicesupplier = new FactureFournisseur($db); {
$tmpdonation = new Don($db); $numd = $db->num_rows($resd);
$upload_dir = ''; $tmpinvoice = new Facture($db);
$i = 0; $tmpinvoicesupplier = new FactureFournisseur($db);
while ($i < $numd) $tmpdonation = new Don($db);
{
$objd = $db->fetch_object($resd);
switch ($objd->item) $upload_dir = '';
{ $i = 0;
case "Invoice": while ($i < $numd)
$subdir = ''; {
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $objd = $db->fetch_object($resd);
$upload_dir = $conf->facture->dir_output.'/'.$subdir;
$link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SupplierInvoice":
$tmpinvoicesupplier->fetch($objd->id);
$subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
$link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "ExpenseReport":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
$link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SalaryPayment":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->salaries->dir_output.'/'.$subdir;
$link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "Donation":
$tmpdonation->fetch($objp->id);
$subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->don->dir_output.'/'.$subdir;
$link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SocialContributions":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->tax->dir_output.'/'.$subdir;
$link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
default:
$subdir = '';
$upload_dir = '';
$link = '';
break;
}
if (!empty($upload_dir)) switch ($objd->item)
{ {
$result = true; case "Invoice":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->facture->dir_output.'/'.$subdir;
$link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SupplierInvoice":
$tmpinvoicesupplier->fetch($objd->id);
$subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
$link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "ExpenseReport":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
$link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SalaryPayment":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->salaries->dir_output.'/'.$subdir;
$link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "Donation":
$tmpdonation->fetch($objp->id);
$subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->don->dir_output.'/'.$subdir;
$link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SocialContributions":
$subdir = '';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->tax->dir_output.'/'.$subdir;
$link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
default:
$subdir = '';
$upload_dir = '';
$link = '';
break;
}
$files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); if (!empty($upload_dir))
//var_dump($upload_dir); {
//var_dump($files); $result = true;
if (count($files) < 1) $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1);
{ //var_dump($upload_dir);
$nofile = array(); //var_dump($files);
$nofile['id'] = $objd->id; if (count($files) < 1)
$nofile['entity'] = $objd->entity; {
$nofile['date'] = $db->idate($objd->date); $nofile = array();
$nofile['paid'] = $objd->paid; $nofile['id'] = $objd->id;
$nofile['amount_ht'] = $objd->total_ht; $nofile['entity'] = $objd->entity;
$nofile['amount_ttc'] = $objd->total_ttc; $nofile['date'] = $db->idate($objd->date);
$nofile['amount_vat'] = $objd->total_vat; $nofile['date_due'] = $db->idate($objd->date_due);
$nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); $nofile['paid'] = $objd->paid;
$nofile['fk'] = $objd->fk_soc; $nofile['amount_ht'] = $objd->total_ht;
$nofile['item'] = $objd->item; $nofile['amount_ttc'] = $objd->total_ttc;
$nofile['thirdparty_name'] = $objd->thirdparty_name; $nofile['amount_vat'] = $objd->total_vat;
$nofile['thirdparty_code'] = $objd->thirdparty_code; $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id);
$nofile['country_code'] = $objd->country_code; $nofile['fk'] = $objd->fk_soc;
$nofile['vatnum'] = $objd->vatnum; $nofile['item'] = $objd->item;
$nofile['thirdparty_name'] = $objd->thirdparty_name;
$nofile['thirdparty_code'] = $objd->thirdparty_code;
$nofile['country_code'] = $objd->country_code;
$nofile['vatnum'] = $objd->vatnum;
$filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile;
} }
else else
{ {
foreach ($files as $key => $file) foreach ($files as $key => $file)
{ {
$file['id'] = $objd->id; $file['id'] = $objd->id;
$file['entity'] = $objd->entity; $file['entity'] = $objd->entity;
$file['date'] = $db->idate($objd->date); $file['date'] = $db->idate($objd->date);
$file['paid'] = $objd->paid; $file['date_due'] = $db->idate($objd->date_due);
$file['amount_ht'] = $objd->total_ht; $file['paid'] = $objd->paid;
$file['amount_ttc'] = $objd->total_ttc; $file['amount_ht'] = $objd->total_ht;
$file['amount_vat'] = $objd->total_vat; $file['amount_ttc'] = $objd->total_ttc;
$file['ref'] = ($objd->ref ? $objd->ref : $objd->id); $file['amount_vat'] = $objd->total_vat;
$file['fk'] = $objd->fk_soc; $file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
$file['item'] = $objd->item; $file['fk'] = $objd->fk_soc;
$file['item'] = $objd->item;
$file['thirdparty_name'] = $objd->thirdparty_name; $file['thirdparty_name'] = $objd->thirdparty_name;
$file['thirdparty_code'] = $objd->thirdparty_code; $file['thirdparty_code'] = $objd->thirdparty_code;
$file['country_code'] = $objd->country_code; $file['country_code'] = $objd->country_code;
$file['vatnum'] = $objd->vatnum; $file['vatnum'] = $objd->vatnum;
// Save record into array (only the first time it is found) // Save record into array (only the first time it is found)
if (empty($filesarray[$file['item'].'_'.$file['id']])) { if (empty($filesarray[$file['item'].'_'.$file['id']])) {
$filesarray[$file['item'].'_'.$file['id']] = $file; $filesarray[$file['item'].'_'.$file['id']] = $file;
} }
// Add or concat file // Add or concat file
if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) {
$filesarray[$file['item'].'_'.$file['id']]['files'] = array(); $filesarray[$file['item'].'_'.$file['id']]['files'] = array();
} }
$filesarray[$file['item'].'_'.$file['id']]['files'][] = array('link' => $link.$file['name'], 'name'=>$file['name'], 'ref'=>$file['ref'], 'fullname' => $file['fullname'], 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name']); $filesarray[$file['item'].'_'.$file['id']]['files'][] = array('link' => $link.$file['name'], 'name'=>$file['name'], 'ref'=>$file['ref'], 'fullname' => $file['fullname'], 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name']);
//var_dump($file['item'].'_'.$file['id']); //var_dump($file['item'].'_'.$file['id']);
//var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']);
} }
} }
} }
$i++; $i++;
} }
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
$db->free($resd); $db->free($resd);
}
else {
setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors');
$error++;
}
} }
} }
@ -336,12 +366,14 @@ if ($result && $action == "dl" && !$error)
$log .= ','.$langs->transnoentitiesnoconv("Entity"); $log .= ','.$langs->transnoentitiesnoconv("Entity");
} }
$log .= ','.$langs->transnoentitiesnoconv("Date"); $log .= ','.$langs->transnoentitiesnoconv("Date");
$log .= ','.$langs->transnoentitiesnoconv("DateDue");
$log .= ','.$langs->transnoentitiesnoconv("Ref"); $log .= ','.$langs->transnoentitiesnoconv("Ref");
$log .= ','.$langs->transnoentitiesnoconv("TotalHT"); $log .= ','.$langs->transnoentitiesnoconv("TotalHT");
$log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); $log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
$log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); $log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
$log .= ','.$langs->transnoentitiesnoconv("Paid"); $log .= ','.$langs->transnoentitiesnoconv("Paid");
$log .= ',filename,item_id'; $log .= ','.$langs->transnoentitiesnoconv("Document");
$log .= ','.$langs->transnoentitiesnoconv("ItemID");
$log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); $log .= ','.$langs->transnoentitiesnoconv("ThirdParty");
$log .= ','.$langs->transnoentitiesnoconv("Code"); $log .= ','.$langs->transnoentitiesnoconv("Code");
$log .= ','.$langs->transnoentitiesnoconv("Country"); $log .= ','.$langs->transnoentitiesnoconv("Country");
@ -356,29 +388,31 @@ if ($result && $action == "dl" && !$error)
{ {
foreach ($filesarray as $key => $file) foreach ($filesarray as $key => $file)
{ {
foreach($file['files'] as $filecursor) { foreach ($file['files'] as $filecursor) {
if (file_exists($filecursor["fullname"])) { if (file_exists($filecursor["fullname"])) {
$zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]);
} }
} }
$log .= $file['item']; $log .= '"'.$langs->trans($file['item']).'"';
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc))
{ {
$log .= ','.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]); $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"';
} }
$log .= ','.dol_print_date($file['date'], 'dayrfc'); $log .= ','.dol_print_date($file['date'], 'dayrfc');
$log .= ','.$file['ref']; $log .= ','.dol_print_date($file['date_due'], 'dayrfc');
$log .= ',"'.$file['ref'].'"';
$log .= ','.$file['amount_ht']; $log .= ','.$file['amount_ht'];
$log .= ','.$file['amount_ttc']; $log .= ','.$file['amount_ttc'];
$log .= ','.$file['amount_vat']; $log .= ','.$file['amount_vat'];
$log .= ','.$file['paid']; $log .= ','.$file['paid'];
$log .= ','.$file["name"]; $log .= ',"'.$file["name"].'"';
$log .= ','.$file['fk']; $log .= ','.$file['fk'];
$log .= ','.$file['thirdparty_name']; $log .= ',"'.$file['thirdparty_name'].'"';
$log .= ','.$file['thirdparty_code']; $log .= ',"'.$file['thirdparty_code'].'"';
$log .= ','.$file['country_code']; $log .= ',"'.$file['country_code'].'"';
$log .= ',"'.$file['vatnum'].'"'."\n"; $log .= ',"'.$file['vatnum'].'"';
$log .= "\n";
} }
$zip->addFromString('transactions.csv', $log); $zip->addFromString('transactions.csv', $log);
$zip->close(); $zip->close();
@ -406,6 +440,8 @@ if ($result && $action == "dl" && !$error)
$form = new Form($db); $form = new Form($db);
$userstatic = new User($db); $userstatic = new User($db);
$invoice = new Facture($db);
$supplier_invoice = new FactureFournisseur($db);
$title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List");
$help_url = ''; $help_url = '';
@ -431,9 +467,9 @@ print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc))
{ {
$mc->getInfo($conf->entity); $mc->getInfo($conf->entity);
print '<span class="marginleftonly marginrightonly">('.$langs->trans("Entity").' : '; print '<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)?' opacitymedium':'').'">('.$langs->trans("Entity").' : ';
print "<td>"; print "<td>";
if (! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true);
} else { } else {
print $mc->label; print $mc->label;
@ -442,6 +478,21 @@ if (!empty($conf->multicompany->enabled) && is_object($mc))
print ")</span>\n"; print ")</span>\n";
} }
print '<br>';
$listofchoices = array(
'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills'),
'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills'),
'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips'),
'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation'),
'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'),
'selectsocialcontributions'=>array('label'=>'SocialContributions')
);
foreach($listofchoices as $choice => $val) {
$checked = (((! GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice))?' checked="checked"':'');
print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" name="'.$choice.'" value="1"'.$checked.'> '.$langs->trans($val['label']).'</div>';
}
print '<input class="button" type="submit" name="search" value="'.$langs->trans("Search").'">'; print '<input class="button" type="submit" name="search" value="'.$langs->trans("Search").'">';
print '</form>'."\n"; print '</form>'."\n";
@ -457,7 +508,9 @@ if (!empty($date_start) && !empty($date_stop))
$param .= '&date_stopday='.GETPOST('date_stopday', 'int'); $param .= '&date_stopday='.GETPOST('date_stopday', 'int');
$param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
$param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
foreach($listofchoices as $choice => $val) {
$param.='&'.$choice.'='.(GETPOST($choice, 'int')?1:0);
}
print '<form name="dl" action="?action=dl" method="POST" >'."\n"; print '<form name="dl" action="?action=dl" method="POST" >'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -465,14 +518,9 @@ if (!empty($date_start) && !empty($date_stop))
print '<input type="hidden" name="date_start" value="'.dol_print_date($date_start, 'dayxcard').'" />'; print '<input type="hidden" name="date_start" value="'.dol_print_date($date_start, 'dayxcard').'" />';
print '<input type="hidden" name="date_stop" value="'.dol_print_date($date_stop, 'dayxcard').'" />'; print '<input type="hidden" name="date_stop" value="'.dol_print_date($date_stop, 'dayxcard').'" />';
foreach($listofchoices as $choice => $val) {
//print '<input type="hidden" name="date_stopDay" value="'.dol_print_date($date_stop, '%d').'" />'; print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
//print '<input type="hidden" name="date_stopMonth" value="'.dol_print_date($date_stop, '%m').'" />'; }
//print '<input type="hidden" name="date_stopYear" value="'.dol_print_date($date_stop, '%Y').'" />';
//print '<input type="hidden" name="date_startDay" value="'.dol_print_date($date_start, '%d').'" />';
//print '<input type="hidden" name="date_startMonth" value="'.dol_print_date($date_start, '%m').'" />';
//print '<input type="hidden" name="date_startYear" value="'.dol_print_date($date_start, '%m').'" />';
print '<input class="butAction" type="submit" value="'.$langs->trans("Download").'" />'; print '<input class="butAction" type="submit" value="'.$langs->trans("Download").'" />';
print '</form>'."\n"; print '</form>'."\n";
@ -484,7 +532,8 @@ if (!empty($date_start) && !empty($date_stop))
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap ');
print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
print '<td>'.$langs->trans("Ref").'</td>'; print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
print '<td>'.$langs->trans("Document").'</td>'; print '<td>'.$langs->trans("Document").'</td>';
print '<td>'.$langs->trans("Paid").'</td>'; print '<td>'.$langs->trans("Paid").'</td>';
print '<td align="right">'.$langs->trans("TotalHT").'</td>'; print '<td align="right">'.$langs->trans("TotalHT").'</td>';
@ -529,14 +578,32 @@ if (!empty($date_start) && !empty($date_stop))
print dol_print_date($data['date'], 'day'); print dol_print_date($data['date'], 'day');
print "</td>\n"; print "</td>\n";
// Date
print '<td class="center">';
print dol_print_date($data['date_due'], 'day');
print "</td>\n";
// Ref // Ref
print '<td aling="left">'.$data['ref'].'</td>'; print '<td class="nowraponall">';
if ($data['item'] == 'Invoice') {
$invoice->id = $data['id'];
$invoice->ref = $data['ref'];
print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'SupplierInvoice') {
$supplier_invoice->id = $data['id'];
$supplier_invoice->ref = $data['ref'];
print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} else {
print $data['ref'];
}
print '</td>';
// File link // File link
print '<td>'; print '<td>';
if (! empty($data['files'])) if (!empty($data['files']))
{ {
foreach($data['files'] as $filecursor) { foreach ($data['files'] as $filecursor) {
print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank">'.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).'</a><br>'; print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank">'.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).'</a><br>';
} }
} }
@ -584,6 +651,7 @@ if (!empty($date_start) && !empty($date_stop))
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
print '<td></td>';
print '<td align="right">'.price(price2num($totalET, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalET, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalIT, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalVAT, 'MT')).'</td>';

View File

@ -137,9 +137,9 @@ if ($id > 0 || !empty($ref)) {
$modulepart = 'bank'; $modulepart = 'bank';
$permission = $user->rights->banque->modifier; $permission = $user->rights->banque->modifier;
$permtoedit = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier;
$param = '&id='.$object->id.'&num='.$num; $param = '&id='.$object->id.'&num='.urlencode($num);
$uri = '&num='.$num; $moreparam = '&num='.urlencode($num);;
$relativepathwithnofile = $id."/statement/".$num."/"; $relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($num)."/";
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

@ -1337,6 +1337,10 @@ class Account extends CommonObject
$label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number); $label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
$label .= '<br><b>'.$langs->trans('AccountancyJournal').':</b> '.$this->accountancy_journal; $label .= '<br><b>'.$langs->trans('AccountancyJournal').':</b> '.$this->accountancy_journal;
} }
if (isset($this->status)) {
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5);
}
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id;

View File

@ -255,13 +255,14 @@ else
$px1->draw($file, $fileurl); $px1->draw($file, $fileurl);
$show1 = $px1->show(); $show1 = $px1->show();
unset($graph_datas);
unset($px1); $px1 = null;
unset($datas); $graph_datas =null;
unset($datamin); $datas = null;
unset($dataall); $datamin = null;
unset($labels); $dataall = null;
unset($amounts); $labels = null;
$amounts = null;
} }
// Graph Balance for the year // Graph Balance for the year
@ -392,13 +393,13 @@ else
$show2 = $px2->show(); $show2 = $px2->show();
unset($px2); $px2 = null;
unset($graph_datas); $graph_datas =null;
unset($datas); $datas = null;
unset($datamin); $datamin = null;
unset($dataall); $dataall = null;
unset($labels); $labels = null;
unset($amounts); $amounts = null;
} }
// Graph 3 - Balance for all time line // Graph 3 - Balance for all time line
@ -460,7 +461,7 @@ else
} }
else else
{ {
$datas[$i] = '' +$solde + $subtotal; $datas[$i] = 0 + $solde + $subtotal;
} }
$datamin[$i] = $object->min_desired; $datamin[$i] = $object->min_desired;
$dataall[$i] = $object->min_allowed; $dataall[$i] = $object->min_allowed;
@ -505,13 +506,13 @@ else
$show3 = $px3->show(); $show3 = $px3->show();
unset($px3); $px3 = null;
unset($graph_datas); $graph_datas =null;
unset($datas); $datas = null;
unset($datamin); $datamin = null;
unset($dataall); $dataall = null;
unset($labels); $labels = null;
unset($amounts); $amounts = null;
} }
// Tableau 4a - Credit/Debit // Tableau 4a - Credit/Debit
@ -634,10 +635,10 @@ else
$show4 = $px4->show(); $show4 = $px4->show();
unset($graph_datas); $px4 = null;
unset($px4); $graph_datas = null;
unset($debits); $debits = null;
unset($credits); $credits = null;
} }
// Tableau 4b - Credit/Debit // Tableau 4b - Credit/Debit
@ -742,10 +743,10 @@ else
$show5 = $px5->show(); $show5 = $px5->show();
unset($graph_datas); $px5 = null;
unset($px5); $graph_datas = null;
unset($debits); $debits = null;
unset($credits); $credits = null;
} }
} }

View File

@ -49,7 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan")); $langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$id = GETPOST('account', 'int'); $id = GETPOST('account', 'int') ? GETPOST('account', 'int') : GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$dvid = GETPOST('dvid', 'alpha'); $dvid = GETPOST('dvid', 'alpha');
$numref = GETPOST('num', 'alpha'); $numref = GETPOST('num', 'alpha');

View File

@ -39,18 +39,18 @@ $langs->loadLangs(array('banks', 'categories', 'bills', 'companies'));
// Security check // Security check
if (isset($_GET["account"]) || isset($_GET["ref"])) if (isset($_GET["account"]) || isset($_GET["ref"]))
{ {
$id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:''); $id = isset($_GET["account"]) ? $_GET["account"] : (isset($_GET["ref"]) ? $_GET["ref"] : '');
} }
$fieldid = isset($_GET["ref"])?'ref':'rowid'; $fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
if ($user->socid) $socid=$user->socid; if ($user->socid) $socid = $user->socid;
$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
$vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"]; $vline = isset($_GET["vline"]) ? $_GET["vline"] : $_POST["vline"];
$page=isset($_GET["page"])?$_GET["page"]:0; $page = isset($_GET["page"]) ? $_GET["page"] : 0;
// 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('banktreso','globalcard')); $hookmanager->initHooks(array('banktreso', 'globalcard'));
/* /*
* View * View
@ -61,9 +61,9 @@ $helpurl = "";
llxHeader('', $title, $helpurl); llxHeader('', $title, $helpurl);
$societestatic = new Societe($db); $societestatic = new Societe($db);
$facturestatic=new Facture($db); $facturestatic = new Facture($db);
$facturefournstatic=new FactureFournisseur($db); $facturefournstatic = new FactureFournisseur($db);
$socialcontribstatic=new ChargeSociales($db); $socialcontribstatic = new ChargeSociales($db);
$form = new Form($db); $form = new Form($db);
@ -81,17 +81,17 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$object = new Account($db); $object = new Account($db);
if ($_GET["account"]) if ($_GET["account"])
{ {
$result=$object->fetch($_GET["account"]); $result = $object->fetch($_GET["account"]);
} }
if ($_GET["ref"]) if ($_GET["ref"])
{ {
$result=$object->fetch(0, $_GET["ref"]); $result = $object->fetch(0, $_GET["ref"]);
$_GET["account"]=$object->id; $_GET["account"] = $object->id;
} }
// Onglets // Onglets
$head=bank_prepare_head($object); $head = bank_prepare_head($object);
dol_fiche_head($head, 'cash', $langs->trans("FinancialAccount"), 0, 'account'); dol_fiche_head($head, 'cash', $langs->trans("FinancialAccount"), 0, 'account');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -103,7 +103,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
print '<br>'; print '<br>';
$solde = $object->solde(0); $solde = $object->solde(0);
if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)$colspan = 6; if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)$colspan = 6;
else $colspan = 5; else $colspan = 5;
// Show next coming entries // Show next coming entries
@ -114,7 +114,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("DateDue").'</td>'; print '<td>'.$langs->trans("DateDue").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED )print '<td>'.$langs->trans("Entity").'</td>'; if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)print '<td>'.$langs->trans("Entity").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>'; print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td class="right">'.$langs->trans("Debit").'</td>'; print '<td class="right">'.$langs->trans("Debit").'</td>';
print '<td class="right">'.$langs->trans("Credit").'</td>'; print '<td class="right">'.$langs->trans("Credit").'</td>';
@ -139,54 +139,54 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// Customer invoices // Customer invoices
$sql = "SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; $sql = "SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
$sql.= " s.rowid as socid, s.nom as name, s.fournisseur"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
$sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $sql .= " WHERE f.entity IN (".getEntity('invoice').")";
$sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid $sql .= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid
$sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice $sql .= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice
$sql.= " ORDER BY dlr ASC"; $sql .= " ORDER BY dlr ASC";
$sqls[] = $sql; $sqls[] = $sql;
// Supplier invoices // Supplier invoices
$sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,";
$sql.= " s.rowid as socid, s.nom as name, s.fournisseur"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid";
$sql.= " WHERE ff.entity = ".$conf->entity; $sql .= " WHERE ff.entity = ".$conf->entity;
$sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid $sql .= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid
$sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice $sql .= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice
$sql.= " ORDER BY dlr ASC"; $sql .= " ORDER BY dlr ASC";
$sqls[] = $sql; $sqls[] = $sql;
// Social contributions // Social contributions
$sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr";
$sql.= ", cs.fk_account"; $sql .= ", cs.fk_account";
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id";
$sql.= " WHERE cs.entity = ".$conf->entity; $sql .= " WHERE cs.entity = ".$conf->entity;
$sql.= " AND cs.paye = 0"; // Not paid $sql .= " AND cs.paye = 0"; // Not paid
$sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution $sql .= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution
$sql.= " ORDER BY dlr ASC"; $sql .= " ORDER BY dlr ASC";
$sqls[] = $sql; $sqls[] = $sql;
// others sql // others sql
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook) and isset($hookmanager->resArray['sql'])){ if (empty($reshook) and isset($hookmanager->resArray['sql'])) {
$sqls[] = $hookmanager->resArray['sql']; $sqls[] = $hookmanager->resArray['sql'];
} }
$error=0; $error = 0;
$tab_sqlobjOrder=array(); $tab_sqlobjOrder = array();
$tab_sqlobj=array(); $tab_sqlobj = array();
foreach($sqls as $sql){ foreach ($sqls as $sql) {
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
while ($sqlobj = $db->fetch_object($resql)) { while ($sqlobj = $db->fetch_object($resql)) {
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); $tab_sqlobjOrder[] = $db->jdate($sqlobj->dlr);
} }
$db->free($resql); $db->free($resql);
} else { } else {
@ -195,13 +195,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
} }
// Sort array // Sort array
if (! $error) if (!$error)
{ {
array_multisort($tab_sqlobjOrder, $tab_sqlobj); array_multisort($tab_sqlobjOrder, $tab_sqlobj);
// Apply distinct filter // Apply distinct filter
foreach ($tab_sqlobj as $key=>$value) { foreach ($tab_sqlobj as $key=>$value) {
$tab_sqlobj[$key] = "'" . serialize($value) . "'"; $tab_sqlobj[$key] = "'".serialize($value)."'";
} }
$tab_sqlobj = array_unique($tab_sqlobj); $tab_sqlobj = array_unique($tab_sqlobj);
foreach ($tab_sqlobj as $key=>$value) { foreach ($tab_sqlobj as $key=>$value) {
@ -221,52 +221,52 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
if ($obj->family == 'invoice_supplier') if ($obj->family == 'invoice_supplier')
{ {
$showline=1; $showline = 1;
// Uncomment this line to avoid to count suppliers credit note (ff.type = 2) // Uncomment this line to avoid to count suppliers credit note (ff.type = 2)
//$showline=(($obj->total_ttc < 0 && $obj->type != 2) || ($obj->total_ttc > 0 && $obj->type == 2)) //$showline=(($obj->total_ttc < 0 && $obj->type != 2) || ($obj->total_ttc > 0 && $obj->type == 2))
if ($showline) if ($showline)
{ {
$ref=$obj->ref; $ref = $obj->ref;
$facturefournstatic->ref=$ref; $facturefournstatic->ref = $ref;
$facturefournstatic->id=$obj->objid; $facturefournstatic->id = $obj->objid;
$facturefournstatic->type=$obj->type; $facturefournstatic->type = $obj->type;
$ref = $facturefournstatic->getNomUrl(1, ''); $ref = $facturefournstatic->getNomUrl(1, '');
$societestatic->id = $obj->socid; $societestatic->id = $obj->socid;
$societestatic->name = $obj->name; $societestatic->name = $obj->name;
$refcomp=$societestatic->getNomUrl(1, '', 24); $refcomp = $societestatic->getNomUrl(1, '', 24);
$totalpayment = -1*$facturefournstatic->getSommePaiement(); // Payment already done $totalpayment = -1 * $facturefournstatic->getSommePaiement(); // Payment already done
} }
} }
if ($obj->family == 'invoice') if ($obj->family == 'invoice')
{ {
$facturestatic->ref=$obj->ref; $facturestatic->ref = $obj->ref;
$facturestatic->id=$obj->objid; $facturestatic->id = $obj->objid;
$facturestatic->type=$obj->type; $facturestatic->type = $obj->type;
$ref = $facturestatic->getNomUrl(1, ''); $ref = $facturestatic->getNomUrl(1, '');
$societestatic->id = $obj->socid; $societestatic->id = $obj->socid;
$societestatic->name = $obj->name; $societestatic->name = $obj->name;
$refcomp=$societestatic->getNomUrl(1, '', 24); $refcomp = $societestatic->getNomUrl(1, '', 24);
$totalpayment = $facturestatic->getSommePaiement(); // Payment already done $totalpayment = $facturestatic->getSommePaiement(); // Payment already done
$totalpayment+= $facturestatic->getSumDepositsUsed(); $totalpayment += $facturestatic->getSumDepositsUsed();
$totalpayment+= $facturestatic->getSumCreditNotesUsed(); $totalpayment += $facturestatic->getSumCreditNotesUsed();
} }
if ($obj->family == 'social_contribution') if ($obj->family == 'social_contribution')
{ {
$socialcontribstatic->ref=$obj->ref; $socialcontribstatic->ref = $obj->ref;
$socialcontribstatic->id=$obj->objid; $socialcontribstatic->id = $obj->objid;
$socialcontribstatic->label=$obj->type; $socialcontribstatic->label = $obj->type;
$ref = $socialcontribstatic->getNomUrl(1, 24); $ref = $socialcontribstatic->getNomUrl(1, 24);
$totalpayment = -1*$socialcontribstatic->getSommePaiement(); // Payment already done $totalpayment = -1 * $socialcontribstatic->getSommePaiement(); // Payment already done
} }
$parameters = array('obj' => $obj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); $parameters = array('obj' => $obj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment);
$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; $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref;
$refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp; $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp;
$totalpayment = isset($hookmanager->resArray['totalpayment']) ? $hookmanager->resArray['totalpayment'] : $totalpayment; $totalpayment = isset($hookmanager->resArray['totalpayment']) ? $hookmanager->resArray['totalpayment'] : $totalpayment;
@ -287,7 +287,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
print "</td>"; print "</td>";
print "<td>".$ref."</td>"; print "<td>".$ref."</td>";
if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) {
if($obj->family == 'invoice'){ if ($obj->family == 'invoice') {
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print "<td>".$mc->label."</td>"; print "<td>".$mc->label."</td>";
} }
@ -313,7 +313,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// Other lines // Other lines
$parameters = array('solde' => $solde); $parameters = array('solde' => $solde);
$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;
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> /* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
/* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* *
* 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
@ -63,11 +64,66 @@ class Invoices extends DolibarrApi
*/ */
public function get($id, $contact_list = 1) public function get($id, $contact_list = 1)
{ {
return $this->_fetch($id, '', '', '', $contact_list);
}
/**
* Get properties of an invoice object by ref
*
* Return an array with invoice informations
*
* @param string $ref Ref of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @url GET ref/{ref}
*
* @throws RestException
*/
public function getByRef($ref, $contact_list = 1)
{
return $this->_fetch('', $ref, '', '', $contact_list);
}
/**
* Get properties of an invoice object by ref_ext
*
* Return an array with invoice informations
*
* @param string $ref_ext External reference of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @url GET ref_ext/{ref_ext}
*
* @throws RestException
*/
public function getByRefExt($ref_ext, $contact_list = 1)
{
return $this->_fetch('', '', $ref_ext, '', $contact_list);
}
/**
* Get properties of an invoice object
*
* Return an array with invoice informations
*
* @param int $id ID of order
* @param string $ref Ref of object
* @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other objec
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @throws RestException
*/
private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1)
{
if (!DolibarrApiAccess::$user->rights->facture->lire) { if (!DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id, $ref, $ref_ext, $ref_int);
if (!$result) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
@ -87,7 +143,7 @@ class Invoices extends DolibarrApi
$this->invoice->fetchObjectLinked(); $this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice); return $this->_cleanObjectDatas($this->invoice);
} }
/** /**
* List invoices * List invoices
@ -424,7 +480,7 @@ class Invoices extends DolibarrApi
* @url DELETE {id}/contact/{rowid} * @url DELETE {id}/contact/{rowid}
* *
* @return array * @return array
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
* @throws RestException 500 * @throws RestException 500
@ -592,6 +648,7 @@ class Invoices extends DolibarrApi
* *
* @return int * @return int
* *
* @throws RestException 304
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
* @throws RestException 400 * @throws RestException 400
@ -1098,6 +1155,7 @@ class Invoices extends DolibarrApi
* @url POST {id}/usediscount/{discountid} * @url POST {id}/usediscount/{discountid}
* *
* @return int * @return int
*
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
@ -1144,6 +1202,7 @@ class Invoices extends DolibarrApi
* @url POST {id}/usecreditnote/{discountid} * @url POST {id}/usecreditnote/{discountid}
* *
* @return int * @return int
*
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
@ -1189,7 +1248,7 @@ class Invoices extends DolibarrApi
* @url GET {id}/payments * @url GET {id}/payments
* *
* @return array * @return array
* *
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
@ -1239,6 +1298,7 @@ class Invoices extends DolibarrApi
* @url POST {id}/payments * @url POST {id}/payments
* *
* @return int Payment ID * @return int Payment ID
*
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
@ -1358,6 +1418,7 @@ class Invoices extends DolibarrApi
* @url POST /paymentsdistributed * @url POST /paymentsdistributed
* *
* @return int Payment ID * @return int Payment ID
*
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 403 * @throws RestException 403

View File

@ -477,7 +477,7 @@ class Facture extends CommonInvoice
$this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project;
$this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'none') : $_facrec->note_public; $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'none') : $_facrec->note_public;
$this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'none') : $_facrec->note_private; $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'none') : $_facrec->note_private;
$this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'apha') : $_facrec->modelpdf; $this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->modelpdf;
$this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id; $this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id;
$this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id; $this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id;
$this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account;
@ -1253,6 +1253,14 @@ class Facture extends CommonInvoice
$line->date_start = $object->lines[$i]->date_start; $line->date_start = $object->lines[$i]->date_start;
$line->date_end = $object->lines[$i]->date_end; $line->date_end = $object->lines[$i]->date_end;
// Multicurrency
$line->fk_multicurrency = $object->lines[$i]->fk_multicurrency;
$line->multicurrency_code = $object->lines[$i]->multicurrency_code;
$line->multicurrency_subprice = $object->lines[$i]->multicurrency_subprice;
$line->multicurrency_total_ht = $object->lines[$i]->multicurrency_total_ht;
$line->multicurrency_total_tva = $object->lines[$i]->multicurrency_total_tva;
$line->multicurrency_total_ttc = $object->lines[$i]->multicurrency_total_ttc;
$line->fk_fournprice = $object->lines[$i]->fk_fournprice; $line->fk_fournprice = $object->lines[$i]->fk_fournprice;
$marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht);
$line->pa_ht = $marginInfos[0]; $line->pa_ht = $marginInfos[0];
@ -1267,6 +1275,7 @@ class Facture extends CommonInvoice
$this->socid = $object->socid; $this->socid = $object->socid;
$this->fk_project = $object->fk_project; $this->fk_project = $object->fk_project;
$this->fk_account = $object->fk_account;
$this->cond_reglement_id = $object->cond_reglement_id; $this->cond_reglement_id = $object->cond_reglement_id;
$this->mode_reglement_id = $object->mode_reglement_id; $this->mode_reglement_id = $object->mode_reglement_id;
$this->availability_id = $object->availability_id; $this->availability_id = $object->availability_id;
@ -1388,6 +1397,9 @@ class Facture extends CommonInvoice
if (!empty($this->total_ttc)) if (!empty($this->total_ttc))
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); $label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
if ($moretitle) $label .= ' - '.$moretitle; if ($moretitle) $label .= ' - '.$moretitle;
if (isset($this->statut) && isset($this->alreadypaid)) {
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5, $this->alreadypaid);
}
} }
$linkclose = ($target ? ' target="'.$target.'"' : ''); $linkclose = ($target ? ' target="'.$target.'"' : '');
@ -2410,12 +2422,23 @@ class Facture extends CommonInvoice
* @param string $force_number Reference to force on invoice * @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $batch_rule [=0] 0 not decrement batch, else batch rule to use
* 1=take in batches ordered by sellby and eatby dates
* @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK
*/ */
public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 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';
$productStatic = null;
$warehouseStatic = null;
if ($batch_rule > 0) {
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/productbatch.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
$productStatic = new Product($this->db);
$warehouseStatic = new Entrepot($this->db);
}
$now = dol_now(); $now = dol_now();
@ -2507,7 +2530,7 @@ class Facture extends CommonInvoice
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num; $this->newref = dol_sanitizeFileName($num);
if ($num) if ($num)
{ {
@ -2557,11 +2580,94 @@ class Facture extends CommonInvoice
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this; $mouvP->origin = &$this;
// We decrease stock for product // We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); if ($this->type == self::TYPE_CREDIT_NOTE) {
else $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num));
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$this->error = $mouvP->error; $this->error = $mouvP->error;
}
} else {
$is_batch_line = false;
if ($batch_rule > 0) {
$productStatic->fetch($this->lines[$i]->fk_product);
if ($productStatic->hasbatch()) {
$is_batch_line = true;
$product_qty_remain = $this->lines[$i]->qty;
$sortfield = null;
$sortorder = null;
// find all batch order by sellby (DLC) and eatby dates (DLUO) first
if ($batch_rule == Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST) {
$sortfield = 'pl.sellby,pl.eatby,pb.qty,pl.rowid';
$sortorder = 'ASC,ASC,ASC,ASC';
}
$resBatchList = Productbatch::findAllForProduct($this->db, $productStatic->id, $idwarehouse, (!empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) ? null : 0), $sortfield, $sortorder);
if (!is_array($resBatchList)) {
$error++;
$this->error = $this->db->lasterror();
}
if (!$error) {
$batchList = $resBatchList;
if (empty($batchList)) {
$error++;
$langs->load('errors');
$warehouseStatic->fetch($idwarehouse);
$this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
}
foreach ($batchList as $batch) {
if ($batch->qty <= 0) continue; // try to decrement only batches have positive quantity first
// enough quantity in this batch
if ($batch->qty >= $product_qty_remain) {
$product_batch_qty = $product_qty_remain;
} // not enough (take all in batch)
else {
$product_batch_qty = $batch->qty;
}
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
break;
}
$product_qty_remain -= $product_batch_qty;
// all product quantity was decremented
if ($product_qty_remain <= 0) break;
}
if (!$error && $product_qty_remain > 0) {
if ($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) {
// take in the first batch
$batch = $batchList[0];
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
}
} else {
$error++;
$langs->load('errors');
$warehouseStatic->fetch($idwarehouse);
$this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
}
}
}
}
}
if (!$is_batch_line) {
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
}
}
} }
} }
} }
@ -4581,18 +4687,18 @@ class Facture extends CommonInvoice
if ($this->statut != Facture::STATUS_VALIDATED) return false; if ($this->statut != Facture::STATUS_VALIDATED) return false;
$hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
if($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit))
{ {
$totalpaye = $this->getSommePaiement(); $totalpaye = $this->getSommePaiement();
$totalpaye = floatval($totalpaye); $totalpaye = floatval($totalpaye);
$RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount();
if($totalpaye >= 0 && $RetainedWarrantyAmount>= 0) if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0)
{ {
if( ($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay) ) if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay))
{ {
$hasDelay = 1; $hasDelay = 1;
} }
elseif($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay) ) elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay))
{ {
$hasDelay = 1; $hasDelay = 1;
} }
@ -4657,8 +4763,8 @@ class Facture extends CommonInvoice
$retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
} }
if ($rounding < 0){ if ($rounding < 0) {
$rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
return round($retainedWarrantyAmount, 2); return round($retainedWarrantyAmount, 2);
} }

View File

@ -33,10 +33,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
//require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
@ -54,6 +51,8 @@ $cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
$socid = GETPOST('socid', 'int');
// Security check // Security check
$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
@ -62,7 +61,6 @@ if ($user->socid) $socid = $user->socid;
$objecttype = 'facture_rec'; $objecttype = 'facture_rec';
if ($action == "create" || $action == "add") $objecttype = ''; if ($action == "create" || $action == "add") $objecttype = '';
$result = restrictedArea($user, 'facture', $id, $objecttype); $result = restrictedArea($user, 'facture', $id, $objecttype);
$projectid = GETPOST('projectid', 'int');
$search_ref = GETPOST('search_ref'); $search_ref = GETPOST('search_ref');
$search_societe = GETPOST('search_societe'); $search_societe = GETPOST('search_societe');
@ -146,6 +144,13 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');
if ($socid > 0) {
$tmpthirdparty = new Societe($db);
$res = $tmpthirdparty->fetch($socid);
if ($res > 0) $search_societe = $tmpthirdparty->name;
}
/* /*
* Actions * Actions
@ -218,6 +223,7 @@ $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['
/* /*
* List mode * List mode
*/ */
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,"; $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
$sql .= " f.datec, f.tms,"; $sql .= " f.datec, f.tms,";
@ -243,6 +249,7 @@ if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
} }
if ($search_ref) $sql .= natural_search('f.titre', $search_ref); if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($socid) $sql .= ' AND s.rowid = '.(int) $socid;
if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1);
@ -286,7 +293,7 @@ if ($resql)
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($socid) $param .= '&socid='.urlencode($socid); if ($socid > 0) $param .= '&socid='.urlencode($socid);
if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month); if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year); if ($search_year) $param .= '&search_year='.urlencode($search_year);
@ -299,12 +306,11 @@ if ($resql)
if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat);
if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode); if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode);
if ($search_payment_type != '') $param .= '&search_payment_type='.urlencode($search_payment_type); if ($search_payment_term != '') $param .= '&search_payment_term='.urlencode($search_payment_term);
if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring); if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring);
if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency); if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency);
if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
if ($option) $param .= "&option=".urlencode($option);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -326,12 +332,16 @@ if ($resql)
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("RepeatableInvoices"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit); $title = $langs->trans("RepeatableInvoices");
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>'; print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>';
$i = 0; $i = 0;
$moreforfilter = '';
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";
@ -467,7 +477,6 @@ if ($resql)
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
@ -527,21 +536,21 @@ if ($resql)
} }
if (!empty($arrayfields['f.total']['checked'])) if (!empty($arrayfields['f.total']['checked']))
{ {
print '<td class="right">'.price($objp->total).'</td>'."\n"; print '<td class="nowrap right">'.price($objp->total).'</td>'."\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total';
$totalarray['val']['f.total'] += $objp->total; $totalarray['val']['f.total'] += $objp->total;
} }
if (!empty($arrayfields['f.tva']['checked'])) if (!empty($arrayfields['f.tva']['checked']))
{ {
print '<td class="right">'.price($objp->total_vat).'</td>'."\n"; print '<td class="nowrap right">'.price($objp->total_vat).'</td>'."\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva';
$totalarray['val']['f.tva'] += $objp->total_vat; $totalarray['val']['f.tva'] += $objp->total_vat;
} }
if (!empty($arrayfields['f.total_ttc']['checked'])) if (!empty($arrayfields['f.total_ttc']['checked']))
{ {
print '<td class="right">'.price($objp->total_ttc).'</td>'."\n"; print '<td class="nowrap right">'.price($objp->total_ttc).'</td>'."\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
$totalarray['val']['f.total_ttc'] += $objp->total_ttc; $totalarray['val']['f.total_ttc'] += $objp->total_ttc;

View File

@ -87,6 +87,11 @@ $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); $search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha');
$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); $search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha');
$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
$search_status = GETPOST('search_status', 'intcomma'); $search_status = GETPOST('search_status', 'intcomma');
$search_paymentmode = GETPOST('search_paymentmode', 'int'); $search_paymentmode = GETPOST('search_paymentmode', 'int');
$search_paymentterms = GETPOST('search_paymentterms', 'int'); $search_paymentterms = GETPOST('search_paymentterms', 'int');
@ -183,6 +188,13 @@ $arrayfields = array(
'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130),
'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140),
'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow
'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>160),
'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170),
'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>180),
'f.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>190),
'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>200),
'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>210),
'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>220), // Not enabled by default because slow
'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'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),
@ -236,6 +248,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_montant_localtax1 = ''; $search_montant_localtax1 = '';
$search_montant_localtax2 = ''; $search_montant_localtax2 = '';
$search_montant_ttc = ''; $search_montant_ttc = '';
$search_multicurrency_code = '';
$search_multicurrency_tx = '';
$search_multicurrency_montant_ht = '';
$search_multicurrency_montant_vat = '';
$search_multicurrency_montant_ttc = '';
$search_status = ''; $search_status = '';
$search_paymentmode = ''; $search_paymentmode = '';
$search_paymentterms = ''; $search_paymentterms = '';
@ -383,6 +400,7 @@ $sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,';
$sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
$sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,';
$sql .= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; $sql .= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,';
$sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.paye as paye, f.fk_statut, f.close_code,';
$sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
@ -394,7 +412,7 @@ $sql .= " country.code as country_code,";
$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";
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed'; if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed';
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
if (!empty($extrafields->attributes[$object->table_element]['label'])) { if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@ -459,6 +477,11 @@ if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_v
if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1);
if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1);
if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
if ($search_multicurrency_code != '') $sql .= ' AND f.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"';
if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
if ($search_status != '-1' && $search_status != '') if ($search_status != '-1' && $search_status != '')
@ -591,6 +614,11 @@ if ($resql)
if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1);
if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2);
if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
if ($search_paymentmode > 0) $param .= '&search_paymentmode='.urlencode($search_paymentmode); if ($search_paymentmode > 0) $param .= '&search_paymentmode='.urlencode($search_paymentmode);
if ($search_paymentterms > 0) $param .= '&search_paymentterms='.urlencode($search_paymentterms); if ($search_paymentterms > 0) $param .= '&search_paymentterms='.urlencode($search_paymentterms);
@ -878,13 +906,11 @@ 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'])) if (!empty($arrayfields['f.retained_warranty']['checked']))
{ {
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
print '</td>'; 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">';
@ -895,6 +921,51 @@ if ($resql)
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['f.multicurrency_code']['checked']))
{
// Currency
print '<td class="liste_titre">';
print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
print '</td>';
}
if (!empty($arrayfields['f.multicurrency_tx']['checked']))
{
// Currency rate
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
print '</td>';
}
if (!empty($arrayfields['f.multicurrency_total_ht']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
print '</td>';
}
if (!empty($arrayfields['f.multicurrency_total_vat']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
print '</td>';
}
if (!empty($arrayfields['f.multicurrency_total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
print '</td>';
}
if (!empty($arrayfields['multicurrency_dynamount_payed']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
if (!empty($arrayfields['multicurrency_rtp']['checked']))
{
print '<td class="liste_titre right">';
print '</td>';
}
if (!empty($arrayfields['f.date_closing']['checked'])) if (!empty($arrayfields['f.date_closing']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
@ -936,31 +1007,38 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $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_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['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);
if (!empty($arrayfields['f.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['multicurrency_rtp']['checked'])) print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields // Hook fields
@ -994,6 +1072,11 @@ if ($resql)
$facturestatic->total_ht = $obj->total_ht; $facturestatic->total_ht = $obj->total_ht;
$facturestatic->total_tva = $obj->total_vat; $facturestatic->total_tva = $obj->total_vat;
$facturestatic->total_ttc = $obj->total_ttc; $facturestatic->total_ttc = $obj->total_ttc;
$facturestatic->multicurrency_code = $obj->multicurrency_code;
$facturestatic->multicurrency_tx = $obj->multicurrency_tx;
$facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
$facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
$facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
$facturestatic->statut = $obj->fk_statut; $facturestatic->statut = $obj->fk_statut;
$facturestatic->close_code = $obj->close_code; $facturestatic->close_code = $obj->close_code;
$facturestatic->total_ttc = $obj->total_ttc; $facturestatic->total_ttc = $obj->total_ttc;
@ -1031,16 +1114,27 @@ if ($resql)
$totaldeposits = $facturestatic->getSumDepositsUsed(); $totaldeposits = $facturestatic->getSumDepositsUsed();
$totalpay = $paiement + $totalcreditnotes + $totaldeposits; $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = price2num($facturestatic->total_ttc - $totalpay); $remaintopay = price2num($facturestatic->total_ttc - $totalpay);
$multicurrency_paiement = $facturestatic->getSommePaiement(1);
$multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
$multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
$multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
$multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
if ($facturestatic->statut == Facture::STATUS_CLOSED && $facturestatic->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment if ($facturestatic->statut == Facture::STATUS_CLOSED && $facturestatic->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment
$remaintopay = 0; $remaintopay = 0;
$multicurrency_remaintopay = 0;
} }
if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consummed if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consummed
$remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id); $remaincreditnote = $discount->getAvailableDiscounts($thirdpartystatic, '', 'rc.fk_facture_source='.$facturestatic->id);
$remaintopay = -$remaincreditnote; $remaintopay = -$remaincreditnote;
$totalpay = price2num($facturestatic->total_ttc - $remaintopay); $totalpay = price2num($facturestatic->total_ttc - $remaintopay);
$multicurrency_remaincreditnote = $discount->getAvailableDiscounts($thirdpartystatic, '', 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
$multicurrency_remaintopay = -$multicurrency_remaincreditnote;
$multicurrency_totalpay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
} }
$facturestatic->alreadypaid = $paiement;
print '<tr class="oddeven"'; print '<tr class="oddeven"';
if ($contextpage == 'poslist') if ($contextpage == 'poslist')
{ {
@ -1304,6 +1398,55 @@ if ($resql)
$totalarray['val']['rtp'] += $remaintopay; $totalarray['val']['rtp'] += $remaintopay;
} }
// Currency
if (!empty($arrayfields['f.multicurrency_code']['checked']))
{
print '<td class="nowrap">'.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Currency rate
if (!empty($arrayfields['f.multicurrency_tx']['checked']))
{
print '<td class="nowrap">';
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount HT
if (!empty($arrayfields['f.multicurrency_total_ht']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount VAT
if (!empty($arrayfields['f.multicurrency_total_vat']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount TTC
if (!empty($arrayfields['f.multicurrency_total_ttc']['checked']))
{
print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
if (!empty($arrayfields['multicurrency_dynamount_payed']['checked']))
{
print '<td class="right nowrap">'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
if (!$i) $totalarray['nbfield']++;
}
// Pending amount
if (!empty($arrayfields['multicurrency_rtp']['checked']))
{
print '<td class="right nowrap">';
print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '&nbsp;');
print '</td>'; // TODO Use a denormalized field
if (!$i) $totalarray['nbfield']++;
}
// 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

View File

@ -455,7 +455,7 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid"; $sql .= ", s.rowid as socid";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email";
$sql .= ", SUM(pf.amount) as am"; $sql .= ", SUM(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
@ -503,10 +503,14 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->
$thirdpartystatic->id = $obj->socid; $thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name; $thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
$thirdpartystatic->country_id = 0;
$thirdpartystatic->country_code = '';
$thirdpartystatic->client = 0;
$thirdpartystatic->fournisseur = 1; $thirdpartystatic->fournisseur = 1;
//$thirdpartystatic->code_client = $obj->code_client; $thirdpartystatic->code_client = '';
$thirdpartystatic->code_fournisseur = $obj->code_fournisseur; $thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
//$thirdpartystatic->code_compta = $obj->code_compta; $thirdpartystatic->code_compta = '';
$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
print '<tr class="oddeven nowraponall"><td>'; print '<tr class="oddeven nowraponall"><td>';

View File

@ -266,8 +266,8 @@ if (empty($reshook))
$paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
$paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->num_payment = GETPOST('num_paiement', 'alpha');
$paiement->note_private = GETPOST('comment', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha');
$paiement->num_paiement = $paiement->num_payment; // For bacward compatibility $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
$paiement->note = $paiement->note_private; // For bacward compatibility $paiement->note = $paiement->note_private; // For bacward compatibility
if (!$error) if (!$error)
{ {

View File

@ -594,43 +594,43 @@ class Paiement extends CommonObject
{ {
global $conf, $langs, $user; global $conf, $langs, $user;
$error=0; $error = 0;
$bank_line_id=0; $bank_line_id = 0;
if (! empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
if ($accountid <= 0) if ($accountid <= 0)
{ {
$this->error='Bad value for parameter accountid='.$accountid; $this->error = 'Bad value for parameter accountid='.$accountid;
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR); dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR);
return -1; return -1;
} }
$this->db->begin(); $this->db->begin();
$this->fk_account=$accountid; $this->fk_account = $accountid;
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
dol_syslog("$user->id, $mode, $label, $this->fk_account, $emetteur_nom, $emetteur_banque"); dol_syslog("$user->id, $mode, $label, $this->fk_account, $emetteur_nom, $emetteur_banque");
$acc = new Account($this->db); $acc = new Account($this->db);
$result=$acc->fetch($this->fk_account); $result = $acc->fetch($this->fk_account);
$totalamount=$this->amount; $totalamount = $this->amount;
if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility if (empty($totalamount)) $totalamount = $this->total; // For backward compatibility
// if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me) // if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me)
if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount=$this->multicurrency_amount; if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount = $this->multicurrency_amount;
if ($mode == 'payment_supplier') $totalamount=-$totalamount; if ($mode == 'payment_supplier') $totalamount = -$totalamount;
// Insert payment into llx_bank // Insert payment into llx_bank
$bank_line_id = $acc->addline( $bank_line_id = $acc->addline(
$this->datepaye, $this->datepaye,
$this->paiementid, // Payment mode id or code ("CHQ or VIR for example") $this->paiementid, // Payment mode id or code ("CHQ or VIR for example")
$label, $label,
$totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note) $totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note)
$this->num_payment, $this->num_payment,
'', '',
$user, $user,

View File

@ -67,8 +67,7 @@ if (!$sortorder) $sortorder = 'ASC';
// Date range // Date range
$year = GETPOST('year', 'int'); $year = GETPOST('year', 'int');
if (empty($year)) if (empty($year)) {
{
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$month_current = strftime("%m", dol_now()); $month_current = strftime("%m", dol_now());
$year_start = $year_current; $year_start = $year_current;
@ -114,7 +113,7 @@ $tmps = dol_getdate($date_start);
$year_start = $tmps['year']; $year_start = $tmps['year'];
$tmpe = dol_getdate($date_end); $tmpe = dol_getdate($date_end);
$year_end = $tmpe['year']; $year_end = $tmpe['year'];
$nbofyear = ($year_end - $start_year) + 1; $nbofyear = ($year_end - $year_start) + 1;
//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); //var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour'));
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
@ -193,17 +192,21 @@ if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
} }
// Show report array // Show report array
$param = '&modecompta='.$modecompta; $param = '&modecompta='.urlencode($modecompta).'&showaccountdetail='.urlencode($showaccountdetail);
if ($date_startday) $param .= '&date_startday='.$date_startday; if ($date_startday) $param .= '&date_startday='.$date_startday;
if ($date_startmonth) $param .= '&date_startmonth='.$date_startmonth; if ($date_startmonth) $param .= '&date_startmonth='.$date_startmonth;
if ($date_startyear) $param .= '&date_startyear='.$date_startyear; if ($date_startyear) $param .= '&date_startyear='.$date_startyear;
if ($date_endday) $param .= '&date_endday='.$date_endday; if ($date_endday) $param .= '&date_endday='.$date_endday;
if ($date_endmonth) $param .= '&date_endmonth='.$date_endmonth; if ($date_endmonth) $param .= '&date_endmonth='.$date_endmonth;
if ($date_endyear) $param .= '&date_endyear='.$date_startyear; if ($date_endyear) $param .= '&date_endyear='.$date_endyear;
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 '); if ($modecompta == 'BOOKKEEPING') {
print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 ');
} else {
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'width200 ');
}
print_liste_field_titre(''); print_liste_field_titre('');
if ($modecompta == 'BOOKKEEPING') if ($modecompta == 'BOOKKEEPING')
{ {
@ -243,7 +246,7 @@ if ($modecompta == 'BOOKKEEPING')
$sql .= " AND f.entity = ".$conf->entity; $sql .= " AND f.entity = ".$conf->entity;
if (!empty($date_start) && !empty($date_end)) if (!empty($date_start) && !empty($date_end))
$sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; $sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
$sql .= " GROUP BY pcg_type, pcg_subtype, name, socid"; $sql .= " GROUP BY pcg_type, name, socid";
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$oldpcgtype = ''; $oldpcgtype = '';

View File

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('compta', 'banks', 'bills')); $langs->loadLangs(array('compta', 'banks', 'bills'));
@ -97,8 +97,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_day_lim = ''; $search_day_lim = '';
$search_year_lim = ''; $search_year_lim = '';
$search_month_lim = ''; $search_month_lim = '';
$search_project_ref=''; $search_project_ref = '';
$search_project=''; $search_project = '';
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
@ -112,25 +112,25 @@ $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$formsocialcontrib = new FormSocialContrib($db); $formsocialcontrib = new FormSocialContrib($db);
$chargesociale_static = new ChargeSociales($db); $chargesociale_static = new ChargeSociales($db);
if (! empty($conf->projet->enabled)) $projectstatic=new Project($db); if (!empty($conf->projet->enabled)) $projectstatic = new Project($db);
llxHeader('', $langs->trans("SocialContributions")); llxHeader('', $langs->trans("SocialContributions"));
$sql = "SELECT cs.rowid as id, cs.fk_type as type, "; $sql = "SELECT cs.rowid as id, cs.fk_type as type, ";
$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,";
if (! empty($conf->projet->enabled)) $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; if (!empty($conf->projet->enabled)) $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
$sql .= " c.libelle as type_label,"; $sql .= " c.libelle as type_label,";
$sql .= " SUM(pc.amount) as alreadypayed"; $sql .= " SUM(pc.amount) as alreadypayed";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
$sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
if (! empty($conf->projet->enabled)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet"; if (!empty($conf->projet->enabled)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
$sql .= " WHERE cs.fk_type = c.id"; $sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND cs.entity = ".$conf->entity; $sql .= " AND cs.entity = ".$conf->entity;
// Search criteria // Search criteria
if ($search_ref) $sql .= " AND cs.rowid=".$db->escape($search_ref); if ($search_ref) $sql .= " AND cs.rowid=".$db->escape($search_ref);
if ($search_label) $sql .= natural_search("cs.libelle", $search_label); if ($search_label) $sql .= natural_search("cs.libelle", $search_label);
if (! empty($conf->projet->enabled)) if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); if (!empty($conf->projet->enabled)) if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref);
if ($search_amount) $sql .= natural_search("cs.amount", $search_amount, 1); if ($search_amount) $sql .= natural_search("cs.amount", $search_amount, 1);
if ($search_status != '' && $search_status >= 0) $sql .= " AND cs.paye = ".$db->escape($search_status); if ($search_status != '' && $search_status >= 0) $sql .= " AND cs.paye = ".$db->escape($search_status);
$sql .= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim); $sql .= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim);
@ -173,7 +173,7 @@ if ($resql)
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid); if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid);
if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status);
@ -229,7 +229,7 @@ if ($resql)
$formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone');
print '</td>'; print '</td>';
// Ref Project // Ref Project
if (! empty($conf->projet->enabled)) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>'; if (!empty($conf->projet->enabled)) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>';
// Date // Date
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
// Period end date // Period end date
@ -258,7 +258,7 @@ if ($resql)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder);
if (! empty($conf->projet->enabled)) print_liste_field_titre('ProjectRef', $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); if (!empty($conf->projet->enabled)) print_liste_field_titre('ProjectRef', $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "periode", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "periode", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder);
@ -276,10 +276,10 @@ if ($resql)
$chargesociale_static->ref = $obj->id; $chargesociale_static->ref = $obj->id;
$chargesociale_static->label = $obj->label; $chargesociale_static->label = $obj->label;
$chargesociale_static->type_label = $obj->type_label; $chargesociale_static->type_label = $obj->type_label;
if (! empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
$projectstatic->id=$obj->project_id; $projectstatic->id = $obj->project_id;
$projectstatic->ref=$obj->project_ref; $projectstatic->ref = $obj->project_ref;
$projectstatic->title=$obj->project_label; $projectstatic->title = $obj->project_label;
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -297,7 +297,7 @@ if ($resql)
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
// Project Ref // Project Ref
if (! empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
print '<td class="nowrap">'; print '<td class="nowrap">';
if ($obj->project_id > 0) if ($obj->project_id > 0)
{ {

View File

@ -31,23 +31,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("products","categories","errors",'accountancy')); $langs->loadLangs(array("products", "categories", "errors", 'accountancy'));
// Security pack (data & check) // Security pack (data & check)
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) $socid = $user->socid;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
$modecompta = $conf->global->ACCOUNTING_MODE; $modecompta = $conf->global->ACCOUNTING_MODE;
if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta");
$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; $sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"];
$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; $sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"];
if (! $sortorder) $sortorder="asc"; if (!$sortorder) $sortorder = "asc";
if (! $sortfield) $sortfield="ref"; if (!$sortfield) $sortfield = "ref";
// Category // Category
$selected_cat = (int) GETPOST('search_categ', 'int'); $selected_cat = (int) GETPOST('search_categ', 'int');
@ -58,11 +58,11 @@ if (GETPOST('subcat', 'alpha') === 'yes') {
} }
// product/service // product/service
$selected_type = GETPOST('search_type', 'int'); $selected_type = GETPOST('search_type', 'int');
if ($selected_type =='') $selected_type = -1; if ($selected_type == '') $selected_type = -1;
// Date range // Date range
$year=GETPOST("year"); $year = GETPOST("year");
$month=GETPOST("month"); $month = GETPOST("month");
$date_startyear = GETPOST("date_startyear"); $date_startyear = GETPOST("date_startyear");
$date_startmonth = GETPOST("date_startmonth"); $date_startmonth = GETPOST("date_startmonth");
$date_startday = GETPOST("date_startday"); $date_startday = GETPOST("date_startday");
@ -79,51 +79,51 @@ if (empty($year))
$month_current = strftime("%m", dol_now()); $month_current = strftime("%m", dol_now());
$year_start = $year; $year_start = $year;
} }
$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Quarter // Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{ {
$q=GETPOST("q", "int"); $q = GETPOST("q", "int");
if (empty($q)) if (empty($q))
{ {
// We define date_start and date_end // We define date_start and date_end
$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_end=$year_start; $year_end = $year_start;
$month_end=$month_start; $month_end = $month_start;
if (! GETPOST("month")) // If month not forced if (!GETPOST("month")) // If month not forced
{ {
if (! GETPOST('year') && $month_start > $month_current) if (!GETPOST('year') && $month_start > $month_current)
{ {
$year_start--; $year_start--;
$year_end--; $year_end--;
} }
$month_end=$month_start-1; $month_end = $month_start - 1;
if ($month_end < 1) $month_end=12; if ($month_end < 1) $month_end = 12;
else $year_end++; else $year_end++;
} }
$date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false); $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
} }
else else
{ {
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
} }
} else { } else {
// TODO We define q // TODO We define q
} }
// $date_start and $date_end are defined. We force $year_start and $nbofyear // $date_start and $date_end are defined. We force $year_start and $nbofyear
$tmps=dol_getdate($date_start); $tmps = dol_getdate($date_start);
$year_start = $tmps['year']; $year_start = $tmps['year'];
$tmpe=dol_getdate($date_end); $tmpe = dol_getdate($date_end);
$year_end = $tmpe['year']; $year_end = $tmpe['year'];
$nbofyear = ($year_end - $year_start) + 1; $nbofyear = ($year_end - $year_start) + 1;
$commonparams=array(); $commonparams = array();
if (!empty($modecompta)) $commonparams['modecompta']=$modecompta; if (!empty($modecompta)) $commonparams['modecompta'] = $modecompta;
if (!empty($sortorder)) $commonparams['sortorder'] = $sortorder; if (!empty($sortorder)) $commonparams['sortorder'] = $sortorder;
if (!empty($sortfield)) $commonparams['sortfield'] = $sortfield; if (!empty($sortfield)) $commonparams['sortfield'] = $sortfield;
@ -142,15 +142,15 @@ $tableparams = array();
if (!empty($selected_cat)) $tableparams['search_categ'] = $selected_cat; if (!empty($selected_cat)) $tableparams['search_categ'] = $selected_cat;
if (!empty($selected_soc)) $tableparams['search_soc'] = $selected_soc; if (!empty($selected_soc)) $tableparams['search_soc'] = $selected_soc;
if (!empty($selected_type)) $tableparams['search_type'] = $selected_type; if (!empty($selected_type)) $tableparams['search_type'] = $selected_type;
$tableparams['subcat'] = ($subcat === true)?'yes':''; $tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
// Adding common parameters // Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams); $allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams); $headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams); $tableparams = array_merge($commonparams, $tableparams);
foreach($allparams as $key => $value) { foreach ($allparams as $key => $value) {
$paramslink .= '&' . $key . '=' . $value; $paramslink .= '&'.$key.'='.$value;
} }
@ -160,127 +160,127 @@ foreach($allparams as $key => $value) {
llxHeader(); llxHeader();
$form=new Form($db); $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
// TODO Report from bookkeeping not yet available, so we switch on report on business events // TODO Report from bookkeeping not yet available, so we switch on report on business events
if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES"; if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES";
if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES"; if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES";
// Show report header // Show report header
if ($modecompta=="CREANCES-DETTES") { if ($modecompta == "CREANCES-DETTES") {
$name=$langs->trans("Turnover").', '.$langs->trans("ByProductsAndServices"); $name = $langs->trans("Turnover").', '.$langs->trans("ByProductsAndServices");
$calcmode=$langs->trans("CalcModeDebt"); $calcmode = $langs->trans("CalcModeDebt");
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')'; //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$description=$langs->trans("RulesCADue"); $description = $langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
} else { } else {
$description.= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
} }
$builddate=dol_now(); $builddate = dol_now();
} }
elseif ($modecompta=="RECETTES-DEPENSES") elseif ($modecompta == "RECETTES-DEPENSES")
{ {
$name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices"); $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices");
$calcmode=$langs->trans("CalcModeEngagement"); $calcmode = $langs->trans("CalcModeEngagement");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')'; //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description=$langs->trans("RulesCAIn"); $description = $langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
$builddate=dol_now(); $builddate = dol_now();
} }
elseif ($modecompta=="BOOKKEEPING") elseif ($modecompta == "BOOKKEEPING")
{ {
} }
elseif ($modecompta=="BOOKKEEPINGCOLLECTED") elseif ($modecompta == "BOOKKEEPINGCOLLECTED")
{ {
} }
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start - 1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start + 1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
else $periodlink = ''; else $periodlink = '';
report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode); report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{ {
print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
} }
$name=array(); $name = array();
// SQL request // SQL request
$catotal=0; $catotal = 0;
$catotal_ht=0; $catotal_ht = 0;
$qtytotal=0; $qtytotal = 0;
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
$sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,";
$sql.= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql .= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,";
$sql.= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; $sql .= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
if($selected_soc > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)"; if ($selected_soc > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
$sql.= ",".MAIN_DB_PREFIX."facturedet as l"; $sql .= ",".MAIN_DB_PREFIX."facturedet as l";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
if ($selected_cat === -2) // Without any category if ($selected_cat === -2) // Without any category
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
} }
elseif ($selected_cat) // Into a specific category elseif ($selected_cat) // Into a specific category
{ {
$sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp";
} }
$sql.= " WHERE l.fk_facture = f.rowid"; $sql .= " WHERE l.fk_facture = f.rowid";
$sql.= " AND f.fk_statut in (1,2)"; $sql .= " AND f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql.= " AND f.type IN (0,1,2,5)"; $sql .= " AND f.type IN (0,1,2,5)";
} else { } else {
$sql.= " AND f.type IN (0,1,2,3,5)"; $sql .= " AND f.type IN (0,1,2,3,5)";
} }
if ($date_start && $date_end) { if ($date_start && $date_end) {
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
} }
if ($selected_type >=0) if ($selected_type >= 0)
{ {
$sql.= " AND l.product_type = ".$selected_type; $sql .= " AND l.product_type = ".$selected_type;
} }
if ($selected_cat === -2) // Without any category if ($selected_cat === -2) // Without any category
{ {
$sql.=" AND cp.fk_product is null"; $sql .= " AND cp.fk_product is null";
} }
elseif ($selected_cat) { // Into a specific category elseif ($selected_cat) { // Into a specific category
$sql.= " AND (c.rowid = ".$selected_cat; $sql .= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat;
$sql.= ")"; $sql .= ")";
$sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; $sql .= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid";
} }
if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc; if ($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc;
$sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type"; $sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type";
$sql.= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
dol_syslog("cabyprodserv", LOG_DEBUG); dol_syslog("cabyprodserv", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i=0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$amount_ht[$obj->rowid] = $obj->amount; $amount_ht[$obj->rowid] = $obj->amount;
$amount[$obj->rowid] = $obj->amount_ttc; $amount[$obj->rowid] = $obj->amount_ttc;
$qty[$obj->rowid] = $obj->qty; $qty[$obj->rowid] = $obj->qty;
$name[$obj->rowid] = $obj->ref . '&nbsp;-&nbsp;' . $obj->label; $name[$obj->rowid] = $obj->ref.'&nbsp;-&nbsp;'.$obj->label;
$type[$obj->rowid] = $obj->product_type; $type[$obj->rowid] = $obj->product_type;
$catotal_ht+=$obj->amount; $catotal_ht += $obj->amount;
$catotal+=$obj->amount_ttc; $catotal += $obj->amount_ttc;
$qtytotal+=$obj->qty; $qtytotal += $obj->qty;
$i++; $i++;
} }
} else { } else {
@ -288,25 +288,25 @@ if ($modecompta == 'CREANCES-DETTES')
} }
// Show Array // Show Array
$i=0; $i = 0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
// Extra parameters management // Extra parameters management
foreach($headerparams as $key => $value) foreach ($headerparams as $key => $value)
{ {
print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
} }
$moreforfilter=''; $moreforfilter = '';
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";
// Category filter // Category filter
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'; print '<td>';
print $langs->trans("Category") . ': ' . $formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', true); print $langs->trans("Category").': '.$formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', true);
print ' '; print ' ';
print $langs->trans("SubCats") . '? '; print $langs->trans("SubCats").'? ';
print '<input type="checkbox" name="subcat" value="yes"'; print '<input type="checkbox" name="subcat" value="yes"';
if ($subcat) { if ($subcat) {
print ' checked'; print ' checked';
@ -314,12 +314,12 @@ if ($modecompta == 'CREANCES-DETTES')
print '>'; print '>';
// type filter (produit/service) // type filter (produit/service)
print ' '; print ' ';
print $langs->trans("Type"). ': '; print $langs->trans("Type").': ';
$form->select_type_of_lines(isset($selected_type)?$selected_type:-1, 'search_type', 1, 1, 1); $form->select_type_of_lines(isset($selected_type) ? $selected_type : -1, 'search_type', 1, 1, 1);
//select thirdparty //select thirdparty
print '</br>'; print '</br>';
print $langs->trans("ThirdParty") . ': ' . $form->select_thirdparty_list($selected_soc, 'search_soc', '', 1); print $langs->trans("ThirdParty").': '.$form->select_thirdparty_list($selected_soc, 'search_soc', '', 1);
print '</td>'; print '</td>';
print '<td colspan="5" class="right">'; print '<td colspan="5" class="right">';
@ -391,16 +391,16 @@ if ($modecompta == 'CREANCES-DETTES')
print "</tr>\n"; print "</tr>\n";
if (count($name)) { if (count($name)) {
foreach($name as $key=>$value) { foreach ($name as $key=>$value) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Product // Product
print "<td>"; print "<td>";
$fullname=$name[$key]; $fullname = $name[$key];
if ($key > 0) { if ($key > 0) {
$linkname='<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"), $type[$key]==0?'product':'service').' '.$fullname.'</a>'; $linkname = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"), $type[$key] == 0 ? 'product' : 'service').' '.$fullname.'</a>';
} else { } else {
$linkname=$langs->trans("PaymentsNotLinkedToProduct"); $linkname = $langs->trans("PaymentsNotLinkedToProduct");
} }
print $linkname; print $linkname;
print "</td>\n"; print "</td>\n";
@ -465,7 +465,7 @@ if ($modecompta == 'CREANCES-DETTES')
// "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an
// invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ?
// Because there is no way to know this, this report is not relevant. // Because there is no way to know this, this report is not relevant.
print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '<br>'; print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant").'<br>';
} }
// End of page // End of page

View File

@ -279,7 +279,7 @@ if ($action == 'create')
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
{ {
print '<tr><td class="fieldrequired">'.$langs->trans("BankAccount").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("BankAccount").'</td><td>';
$form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -70,8 +70,8 @@ if (!$sortfield) $sortfield = "name";
$object = new Tva($db); $object = new Tva($db);
if ($id > 0) $object->fetch($id); if ($id > 0) $object->fetch($id);
$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref);
$modulepart = 'tax'; $modulepart = 'tax-vat';
/* /*
@ -144,7 +144,6 @@ if ($object->id)
dol_fiche_end(); dol_fiche_end();
$modulepart = 'tax';
$permission = $user->rights->tax->charges->creer; $permission = $user->rights->tax->charges->creer;
$permtoedit = $user->rights->fournisseur->facture->creer; $permtoedit = $user->rights->fournisseur->facture->creer;
$param = '&id='.$object->id; $param = '&id='.$object->id;

View File

@ -314,9 +314,9 @@ class Contact extends CommonObject
// Clean parameters // Clean parameters
$this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name);
$this->firstname = trim($this->firstname); $this->firstname = trim($this->firstname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname));
if (empty($this->socid)) $this->socid = 0; if (empty($this->socid)) $this->socid = 0;
if (empty($this->priv)) $this->priv = 0; if (empty($this->priv)) $this->priv = 0;
if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
@ -427,9 +427,9 @@ class Contact extends CommonObject
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
// Clean parameters // Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname));
$this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname);
$this->firstname = trim($this->firstname); $this->firstname = trim($this->firstname);

View File

@ -1704,7 +1704,7 @@ else
if (is_array($extralabelslines) && count($extralabelslines) > 0) { if (is_array($extralabelslines) && count($extralabelslines) > 0) {
$line = new ContratLigne($db); $line = new ContratLigne($db);
$line->fetch_optionals($objp->rowid); $line->fetch_optionals($objp->rowid);
print $line->showOptionals($extrafields, 'view', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $line->showOptionals($extrafields, 'view', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', 1);
} }
} }
// Line in mode update // Line in mode update
@ -1794,7 +1794,7 @@ else
if (is_array($extralabelslines) && count($extralabelslines) > 0) { if (is_array($extralabelslines) && count($extralabelslines) > 0) {
$line = new ContratLigne($db); $line = new ContratLigne($db);
$line->fetch_optionals($objp->rowid); $line->fetch_optionals($objp->rowid);
print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', 1);
} }
} }

View File

@ -517,7 +517,7 @@ class Contrat extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num; $this->newref = dol_sanitizeFileName($num);
if ($num) if ($num)
{ {

View File

@ -741,7 +741,7 @@ while ($i < min($num, $limit))
// Date // Date
if (!empty($arrayfields['c.date_contrat']['checked'])) if (!empty($arrayfields['c.date_contrat']['checked']))
{ {
print '<td class="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').'</td>';
} }
// 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';

View File

@ -128,6 +128,13 @@ if ($action == 'update' && !empty($permissiontoadd))
if ($object->fields[$key]['type'] == 'duration') { if ($object->fields[$key]['type'] == 'duration') {
if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited
} }
elseif ($object->fields[$key]['type'] == 'boolean') {
if (!GETPOSTISSET($key)) {
$object->$key = 0; // use 0 instead null if the field is defined as not null
continue;
}
}
else { else {
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
} }

View File

@ -183,7 +183,8 @@ if ($action == 'add')
(GETPOST('entitycurrentorall', 'alpha')?0:''), (GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile', 'alpha'), GETPOST('langfile', 'alpha'),
1, 1,
(GETPOST('totalizable', 'alpha')?1:0) (GETPOST('totalizable', 'alpha')?1:0),
(GETPOST('printable', 'alpha')?1:0)
); );
if ($result > 0) if ($result > 0)
{ {
@ -352,7 +353,8 @@ if ($action == 'update')
(GETPOST('entitycurrentorall', 'alpha')?0:''), (GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile'), GETPOST('langfile'),
1, 1,
(GETPOST('totalizable', 'alpha')?1:0) (GETPOST('totalizable', 'alpha')?1:0),
(GETPOST('printable', 'alpha')?1:0)
); );
if ($result > 0) if ($result > 0)
{ {

View File

@ -86,7 +86,7 @@ class box_boms extends ModeleBoxes
if ($user->rights->bom->read) if ($user->rights->bom->read)
{ {
$sql = "SELECT p.ref as product_ref"; $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell";
$sql.= ", c.rowid"; $sql.= ", c.rowid";
$sql.= ", c.date_creation"; $sql.= ", c.date_creation";
$sql.= ", c.tms"; $sql.= ", c.tms";
@ -109,11 +109,15 @@ class box_boms extends ModeleBoxes
while ($line < $num) { while ($line < $num) {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$datem=$this->db->jdate($objp->tms); $datem=$this->db->jdate($objp->tms);
$bomstatic->id = $objp->rowid; $bomstatic->id = $objp->rowid;
$bomstatic->ref = $objp->ref; $bomstatic->ref = $objp->ref;
$bomstatic->id = $objp->socid; $bomstatic->id = $objp->socid;
$bomstatic->status = $objp->status; $bomstatic->status = $objp->status;
$productstatic->ref = $objp->product_ref; $productstatic->ref = $objp->product_ref;
$productstatic->status = $objp->tobuy;
$productstatic->status_buy = $objp->tosell;
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="nowraponall"', 'td' => 'class="nowraponall"',

View File

@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/ */
class box_clients extends ModeleBoxes class box_clients extends ModeleBoxes
{ {
public $boxcode="lastcustomers"; public $boxcode = "lastcustomers";
public $boximg="object_company"; public $boximg = "object_company";
public $boxlabel="BoxLastCustomers"; public $boxlabel = "BoxLastCustomers";
public $depends = array("societe"); public $depends = array("societe");
/** /**
@ -61,9 +61,9 @@ class box_clients extends ModeleBoxes
$this->db = $db; $this->db = $db;
// disable box for such cases // disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option
$this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); $this->hidden = !($user->rights->societe->lire && empty($user->socid));
} }
/** /**
@ -77,33 +77,33 @@ class box_clients extends ModeleBoxes
global $user, $langs, $conf; global $user, $langs, $conf;
$langs->load("boxes"); $langs->load("boxes");
$this->max=$max; $this->max = $max;
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$thirdpartystatic=new Societe($this->db); $thirdpartystatic = new Societe($this->db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max));
if ($user->rights->societe->lire) if ($user->rights->societe->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid"; $sql = "SELECT s.nom as name, s.rowid as socid";
$sql.= ", s.code_client"; $sql .= ", s.code_client";
$sql.= ", s.client"; $sql .= ", s.client";
$sql.= ", s.code_fournisseur"; $sql .= ", s.code_fournisseur";
$sql.= ", s.fournisseur"; $sql .= ", s.fournisseur";
$sql.= ", s.code_compta"; $sql .= ", s.code_compta";
$sql.= ", s.code_compta_fournisseur"; $sql .= ", s.code_compta_fournisseur";
$sql.= ", s.logo"; $sql .= ", s.logo";
$sql.= ", s.email"; $sql .= ", s.email";
$sql.= ", s.datec, s.tms, s.status, s.entity"; $sql .= ", s.datec, s.tms, s.status, s.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.client IN (1, 3)"; $sql .= " WHERE s.client IN (1, 3)";
$sql.= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql.= " AND s.rowid = $user->socid"; if ($user->socid) $sql .= " AND s.rowid = $user->socid";
$sql.= " ORDER BY s.tms DESC"; $sql .= " ORDER BY s.tms DESC";
$sql.= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -115,8 +115,8 @@ class box_clients extends ModeleBoxes
while ($line < $num) while ($line < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$datec=$this->db->jdate($objp->datec); $datec = $this->db->jdate($objp->datec);
$datem=$this->db->jdate($objp->tms); $datem = $this->db->jdate($objp->tms);
$thirdpartystatic->id = $objp->socid; $thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name; $thirdpartystatic->name = $objp->name;
$thirdpartystatic->code_client = $objp->code_client; $thirdpartystatic->code_client = $objp->code_client;
@ -148,7 +148,7 @@ class box_clients extends ModeleBoxes
$line++; $line++;
} }
if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers"));
$this->db->free($result); $this->db->free($result);
} }

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat> * Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2020 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
@ -83,6 +84,7 @@ class box_contacts extends ModeleBoxes
if ($user->rights->societe->lire && $user->rights->societe->contact->lire) if ($user->rights->societe->lire && $user->rights->societe->contact->lire)
{ {
$sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
$sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
$sql .= ", s.nom as socname, s.name_alias, s.email as semail"; $sql .= ", s.nom as socname, s.name_alias, s.email as semail";
$sql .= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql .= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur";

View File

@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/ */
class box_fournisseurs extends ModeleBoxes class box_fournisseurs extends ModeleBoxes
{ {
public $boxcode="lastsuppliers"; public $boxcode = "lastsuppliers";
public $boximg="object_company"; public $boximg = "object_company";
public $boxlabel="BoxLastSuppliers"; public $boxlabel = "BoxLastSuppliers";
public $depends = array("fournisseur"); public $depends = array("fournisseur");
/** /**
@ -60,7 +60,7 @@ class box_fournisseurs extends ModeleBoxes
$this->db = $db; $this->db = $db;
$this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); $this->hidden = !($user->rights->societe->lire && empty($user->socid));
} }
/** /**
@ -74,28 +74,28 @@ class box_fournisseurs extends ModeleBoxes
global $conf, $user, $langs; global $conf, $user, $langs;
$langs->load("boxes"); $langs->load("boxes");
$this->max=$max; $this->max = $max;
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$thirdpartystatic=new Societe($this->db); $thirdpartystatic = new Societe($this->db);
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
$thirdpartytmp=new Fournisseur($this->db); $thirdpartytmp = new Fournisseur($this->db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max));
if ($user->rights->societe->lire) if ($user->rights->societe->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,";
$sql.= " s.code_fournisseur, s.email as semail,"; $sql .= " s.code_fournisseur, s.email as semail,";
$sql.= " s.logo, s.code_compta_fournisseur, s.entity"; $sql .= " s.logo, s.code_compta_fournisseur, s.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fournisseur = 1"; $sql .= " WHERE s.fournisseur = 1";
$sql.= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
$sql.= " ORDER BY s.tms DESC "; $sql .= " ORDER BY s.tms DESC ";
$sql.= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -106,8 +106,8 @@ class box_fournisseurs extends ModeleBoxes
while ($line < $num) while ($line < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$datec=$this->db->jdate($objp->datec); $datec = $this->db->jdate($objp->datec);
$datem=$this->db->jdate($objp->tms); $datem = $this->db->jdate($objp->tms);
$thirdpartytmp->id = $objp->socid; $thirdpartytmp->id = $objp->socid;
$thirdpartytmp->name = $objp->name; $thirdpartytmp->name = $objp->name;
$thirdpartytmp->email = $objp->semail; $thirdpartytmp->email = $objp->semail;
@ -135,7 +135,7 @@ class box_fournisseurs extends ModeleBoxes
$line++; $line++;
} }
if ($num==0) $this->info_box_contents[$line][0] = array( if ($num == 0) $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedSuppliers"), 'text'=>$langs->trans("NoRecordedSuppliers"),
); );

View File

@ -33,10 +33,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/ */
class box_propales extends ModeleBoxes class box_propales extends ModeleBoxes
{ {
public $boxcode="lastpropals"; public $boxcode = "lastpropals";
public $boximg="object_propal"; public $boximg = "object_propal";
public $boxlabel="BoxLastProposals"; public $boxlabel = "BoxLastProposals";
public $depends = array("propal"); // conf->propal->enabled public $depends = array("propal"); // conf->propal->enabled
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
@ -61,7 +61,7 @@ class box_propales extends ModeleBoxes
$this->db = $db; $this->db = $db;
$this->hidden = ! ($user->rights->propale->lire); $this->hidden = !($user->rights->propale->lire);
} }
/** /**
@ -74,45 +74,45 @@ class box_propales extends ModeleBoxes
{ {
global $user, $langs, $conf; global $user, $langs, $conf;
$this->max=$max; $this->max = $max;
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$propalstatic=new Propal($this->db); $propalstatic = new Propal($this->db);
$societestatic = new Societe($this->db); $societestatic = new Societe($this->db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals", $max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max));
if ($user->rights->propale->lire) if ($user->rights->propale->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,";
$sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid"; $sql .= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity; $sql .= " AND p.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC ";
else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; else $sql .= " ORDER BY p.tms DESC, p.ref DESC ";
$sql.= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$now=dol_now(); $now = dol_now();
$line = 0; $line = 0;
while ($line < $num) { while ($line < $num) {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$date=$this->db->jdate($objp->dp); $date = $this->db->jdate($objp->dp);
$datec=$this->db->jdate($objp->datec); $datec = $this->db->jdate($objp->datec);
$datem=$this->db->jdate($objp->tms); $datem = $this->db->jdate($objp->tms);
$dateterm=$this->db->jdate($objp->fin_validite); $dateterm = $this->db->jdate($objp->fin_validite);
$dateclose=$this->db->jdate($objp->date_cloture); $dateclose = $this->db->jdate($objp->date_cloture);
$propalstatic->id = $objp->rowid; $propalstatic->id = $objp->rowid;
$propalstatic->ref = $objp->ref; $propalstatic->ref = $objp->ref;
$propalstatic->total_ht = $objp->total_ht; $propalstatic->total_ht = $objp->total_ht;
@ -161,7 +161,7 @@ class box_propales extends ModeleBoxes
$line++; $line++;
} }
if ($num==0) if ($num == 0)
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedProposals"), 'text'=>$langs->trans("NoRecordedProposals"),

View File

@ -91,7 +91,7 @@ class box_services_contracts extends ModeleBoxes
$sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,";
$sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
@ -165,6 +165,9 @@ class box_services_contracts extends ModeleBoxes
$productstatic->ref=$objp->product_ref; $productstatic->ref=$objp->product_ref;
$productstatic->entity=$objp->pentity; $productstatic->entity=$objp->pentity;
$productstatic->label=$objp->plabel; $productstatic->label=$objp->plabel;
$productstatic->status = $objp->tosell;
$productstatic->status_buy = $objp->tobuy;
$text = $productstatic->getNomUrl(1, '', 20); $text = $productstatic->getNomUrl(1, '', 20);
if ($objp->plabel) if ($objp->plabel)
{ {

View File

@ -127,15 +127,17 @@ class box_task extends ModeleBoxes
$boxcontent .= '<button type="submit" class="button">'.$langs->trans("Refresh").'</button>'; $boxcontent .= '<button type="submit" class="button">'.$langs->trans("Refresh").'</button>';
$boxcontent .= '</form>'."\n"; $boxcontent .= '</form>'."\n";
$boxcontent .= '</div>'."\n"; $boxcontent .= '</div>'."\n";
$boxcontent .= '<script type="text/javascript" language="javascript"> if (! empty($conf->use_javascript_ajax)) {
jQuery(document).ready(function() { $boxcontent .= '<script type="text/javascript" language="javascript">
jQuery("#idsubimg'.$this->boxcode.'").click(function() { jQuery(document).ready(function() {
jQuery(".showiffilter'.$this->boxcode.'").toggle(); jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery(".showiffilter'.$this->boxcode.'").toggle();
});
}); });
}); </script>';
</script>'; // set cookie by js
// set cookie by js $boxcontent .= '<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
$boxcontent .= '<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>'; }
$this->info_box_contents[0][] = array( $this->info_box_contents[0][] = array(
'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"',
'td' => 'class="nohover"', 'td' => 'class="nohover"',

View File

@ -49,6 +49,10 @@ abstract class CommonDocGenerator
*/ */
protected $db; protected $db;
/**
* @var Extrafields object
*/
public $extrafieldsCache;
/** /**
* Constructor * Constructor
@ -532,14 +536,16 @@ abstract class CommonDocGenerator
* *
* @param Object $line Object line * @param Object $line Object line
* @param Translate $outputlangs Lang object to use for output * @param Translate $outputlangs Lang object to use for output
* @param int $linenumber The number of the line for the substitution of "object_line_pos"
* @return array Return a substitution array * @return array Return a substitution array
*/ */
public function get_substitutionarray_lines($line, $outputlangs) public function get_substitutionarray_lines($line, $outputlangs, $linenumber = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$resarray = array( $resarray = array(
'line_pos' => $linenumber,
'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs),
'line_product_ref'=>$line->product_ref, 'line_product_ref'=>$line->product_ref,
'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines
@ -788,81 +794,84 @@ abstract class CommonDocGenerator
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label)
{ if (is_array($extrafields->attributes[$object->table_element]['label'])) {
if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label)
{ {
$object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); if($extrafields->attributes[$object->table_element]['type'][$key] == 'price')
$object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); {
//Add value to store price with currency $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]);
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
} //Add value to store price with currency
elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select') $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency']));
{ }
$object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select')
} {
elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]];
$valArray=explode(',', $object->array_options['options_'.$key]); }
$output=array(); elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') {
foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { $valArray=explode(',', $object->array_options['options_'.$key]);
if (in_array($keyopt, $valArray)) { $output=array();
$output[]=$valopt; foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) {
if (in_array($keyopt, $valArray)) {
$output[]=$valopt;
}
} }
$object->array_options['options_'.$key] = implode(', ', $output);
} }
$object->array_options['options_'.$key] = implode(', ', $output); elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date')
}
elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date')
{
if (strlen($object->array_options['options_'.$key])>0)
{ {
$date = $object->array_options['options_'.$key]; if (strlen($object->array_options['options_'.$key])>0)
$object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language
$object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format
$object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format
}
else
{
$object->array_options['options_'.$key] = '';
$object->array_options['options_'.$key.'_locale'] = '';
$object->array_options['options_'.$key.'_rfc'] = '';
}
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
}
elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime')
{
$datetime = $object->array_options['options_'.$key];
$object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language
$object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format
$object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
}
elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link')
{
$id = $object->array_options['options_'.$key];
if ($id != "")
{
$param = $extrafields->attributes[$object->table_element]['param'][$key];
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
$InfoFieldList = explode(":", $param_list[0]);
$classname=$InfoFieldList[0];
$classpath=$InfoFieldList[1];
if (! empty($classpath))
{ {
dol_include_once($InfoFieldList[1]); $date = $object->array_options['options_'.$key];
if ($classname && class_exists($classname)) $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language
$object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format
$object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format
}
else
{
$object->array_options['options_'.$key] = '';
$object->array_options['options_'.$key.'_locale'] = '';
$object->array_options['options_'.$key.'_rfc'] = '';
}
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
}
elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime')
{
$datetime = $object->array_options['options_'.$key];
$object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language
$object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format
$object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
}
elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link')
{
$id = $object->array_options['options_'.$key];
if ($id != "")
{
$param = $extrafields->attributes[$object->table_element]['param'][$key];
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
$InfoFieldList = explode(":", $param_list[0]);
$classname=$InfoFieldList[0];
$classpath=$InfoFieldList[1];
if (! empty($classpath))
{ {
$tmpobject = new $classname($this->db); dol_include_once($InfoFieldList[1]);
$tmpobject->fetch($id); if ($classname && class_exists($classname))
// completely replace the id with the linked object name {
$object->array_options['options_'.$key] = $tmpobject->name; $tmpobject = new $classname($this->db);
$tmpobject->fetch($id);
// completely replace the id with the linked object name
$object->array_options['options_'.$key] = $tmpobject->name;
}
} }
} }
} }
}
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
}
} }
return $array_to_fill; return $array_to_fill;
@ -1074,7 +1083,7 @@ abstract class CommonDocGenerator
* @param float $curY curent Y position * @param float $curY curent Y position
* @param string $colKey the column key * @param string $colKey the column key
* @param string $columnText column text * @param string $columnText column text
* @return int new rank on success and -1 on error * @return null
*/ */
public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '')
{ {
@ -1096,6 +1105,221 @@ abstract class CommonDocGenerator
} }
} }
/**
* get extrafield content for pdf writeHtmlCell compatibility
* usage for PDF line columns and object note block
*
* @param object $object common object
* @param string $extrafieldKey the extrafield key
* @return string
*/
public function getExtrafieldContent($object, $extrafieldKey)
{
global $hookmanager;
if(empty($object->table_element)){ return; }
$extrafieldsKeyPrefix = "options_";
// Cleanup extrafield key to remove prefix if present
$pos = strpos($extrafieldKey, $extrafieldsKeyPrefix);
if($pos===0){
$extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix));
}
$extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
// Load extrafiels if not allready does
if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); }
if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); }
$extrafields = $this->extrafieldsCache;
$extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element);
// TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ...
if($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link'){
// for lack of anything better we cleanup all html tags
$extrafieldOutputContent = dol_string_nohtmltag($extrafieldOutputContent);
}
$parameters = array(
'object' => $object,
'extrafields' => $extrafields,
'extrafieldKey' => $extrafieldKey,
'extrafieldOutputContent' =>& $extrafieldOutputContent
);
$reshook = $hookmanager->executeHooks('getPDFExtrafieldContent', $parameters, $this); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook)
{
$extrafieldOutputContent = $hookmanager->resPrint;
}
return $extrafieldOutputContent;
}
/**
* display extrafields columns content
*
* @param object $object line of common object
* @param Translate $outputlangs Output language
* @param array $params array of additionals parameters
* @return double max y value
*/
public function getExtrafieldsInHtml($object, $outputlangs, $params = array())
{
global $hookmanager;
if(empty($object->table_element)){
return;
}
// Load extrafiels if not allready does
if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); }
if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); }
$extrafields = $this->extrafieldsCache;
$defaultParams = array(
'style' => '',
'display' => 'auto', // auto, table, list
'table' => array(
'maxItemsInRow' => 2,
'cellspacing' => 0,
'cellpadding' => 0,
'border' => 0,
'labelcolwidth' => '25%',
'arrayOfLineBreakType' => array('text', 'html')
),
'list' => array(
'separator' => '<br/>'
),
'auto' => array(
'list' => 0, // 0 for default
'table' => 4 // if there more than x extrafield to display
),
);
$params = $params + $defaultParams;
/**
* @var $extrafields ExtraFields
*/
$html = '';
$fields = array();
if (is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{
// Enable extrafield ?
$enabled = !empty($extrafields->attributes[$object->table_element]['printable'][$key]);
if(empty($enabled)){
continue;
}
$field = new stdClass();
$field->rank = intval($extrafields->attributes[$object->table_element]['pos'][$key]);
$field->content = $this->getExtrafieldContent($object, $key);
$field->label = $outputlangs->transnoentities($label);
$field->type = $extrafields->attributes[$object->table_element]['type'][$key];
$fields[] = $field;
}
}
if(!empty($fields))
{
// Sort extrafields by rank
uasort($fields, function ($a, $b) {
return ($a->rank > $b->rank) ? -1 : 1;
}
);
// define some HTML content with style
$html.= '<style>'.$params['style'].'</style>';
// auto select display format
if($params['display'] == 'auto') {
$lastNnumbItems = 0;
foreach ($params['auto'] as $display => $numbItems){
if($lastNnumbItems <= $numbItems && count($fields) > $numbItems){
$lastNnumbItems = $numbItems;
$params['display'] = $display;
}
}
}
if($params['display'] == 'list') {
// Display in list format
foreach ($fields as $field) {
$html .= !empty($html)?$params['list']['separator']:'';
$html .= '<strong>' . $field->label . ' : </strong>';
$html .= $field->content;
}
}
elseif($params['display'] == 'table') {
// Display in table format
$html .= '<table class="extrafield-table" cellspacing="' . $params['table']['cellspacing'] . '" cellpadding="' . $params['table']['cellpadding'] . '" border="' . $params['table']['border'] . '">';
$html .= "<tr>";
$itemsInRow = 0;
$maxItemsInRow = $params['table']['maxItemsInRow'];
foreach ($fields as $field) {
//$html.= !empty($html)?'<br/>':'';
if ($itemsInRow >= $maxItemsInRow) {
// start a new line
$html .= "</tr><tr>";
$itemsInRow = 0;
}
// for some type we need line break
if (in_array($field->type, $params['table']['arrayOfLineBreakType'])) {
if ($itemsInRow > 0) {
// close table row and empty cols
for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) {
$html .= "<td ></td><td></td>";
}
$html .= "</tr>";
// start a new line
$html .= "<tr>";
}
$itemsInRow = $maxItemsInRow;
$html .= '<td colspan="' . ($maxItemsInRow * 2 - 1) . '">';
$html .= '<strong>' . $field->label . ' :</strong> ';
$html .= $field->content;
$html .= "</td>";
} else {
$itemsInRow++;
$html .= '<td width="'.$params['table']['labelcolwidth'].'" class="extrafield-label">';
$html .= '<strong>' . $field->label . ' :</strong>';
$html .= "</td>";
$html .= '<td class="extrafield-content">';
$html .= $field->content;
$html .= "</td>";
}
}
$html .= "</tr>";
$html .= '</table>';
}
}
return $html;
}
/** /**
* get column status from column key * get column status from column key
@ -1167,4 +1391,81 @@ abstract class CommonDocGenerator
} }
return $this->tabTitleHeight; return $this->tabTitleHeight;
} }
/**
* Define Array Column Field for extrafields
*
* @param object $object common object det
* @param Translate $outputlangs langs
* @param int $hidedetails Do not show line details
* @return null
*/
public function defineColumnExtrafield($object, $outputlangs, $hidedetails = 0)
{
global $conf;
if(!empty($hidedetails)){
return;
}
if(empty($object->table_element)){
return;
}
// Load extrafiels if not allready does
if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); }
if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); }
$extrafields = $this->extrafieldsCache;
if (!empty($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{
// Dont display separator yet even is set to be displayed (not compatible yet)
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate')
{
continue;
}
// Enable extrafield ?
$enabled = !empty($extrafields->attributes[$object->table_element]['printable'][$key]);
// Load language if required
if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
// TODO : add more extrafield customisation capacities for PDF like width, rank...
// set column definition
$def = array(
'rank' => intval($extrafields->attributes[$object->table_element]['pos'][$key]),
'width' => 25, // in mm
'status' => boolval($enabled),
'title' => array(
'label' => $outputlangs->transnoentities($label)
),
'content' => array(
'align' => 'C'
),
'border-left' => true, // add left line separator
);
$alignTypeRight = array('double', 'int', 'price');
if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)){
$def['content']['align'] = 'R';
}
$alignTypeLeft = array('text', 'html');
if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)){
$def['content']['align'] = 'L';
}
// for extrafields we use rank of extrafield to place it on PDF
$this->insertNewColumnDef("options_".$key, $def);
}
}
}
} }

View File

@ -571,7 +571,7 @@ abstract class CommonObject
$return = '<div class="box-flex-item">'; $return = '<div class="box-flex-item">';
$return .= '<div class="info-box info-box-sm">'; $return .= '<div class="info-box info-box-sm">';
$return .= '<span class="info-box-icon bg-infoxbox-action">'; $return .= '<span class="info-box-icon bg-infoxbox-action">';
$return .= '<i class="fa fa-dol-action"></i>'; // Can be image $return .= '<i class="fa fa-dol-action"></i>'; // Can be image
$return .= '</span>'; $return .= '</span>';
$return .= '<div class="info-box-content">'; $return .= '<div class="info-box-content">';
$return .= '<span class="info-box-title">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>'; $return .= '<span class="info-box-title">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
@ -1797,14 +1797,14 @@ abstract class CommonObject
// this->ismultientitymanaged contains // this->ismultientitymanaged contains
// 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
$aliastablesociete = 's'; $aliastablesociete = 's';
if ($this->element == 'societe') $aliastablesociete = 'te'; // te as table_element if ($this->element == 'societe') $aliastablesociete = 'te'; // te as table_element
$sql = "SELECT MAX(te.".$fieldid.")"; $sql = "SELECT MAX(te.".$fieldid.")";
$sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te"; $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
} }
if (isset($this->ismultientitymanaged) && ! is_numeric($this->ismultientitymanaged)) { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
} }
@ -1819,7 +1819,7 @@ abstract class CommonObject
if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility
$sql .= $filter; $sql .= $filter;
} }
if (isset($this->ismultientitymanaged) && ! is_numeric($this->ismultientitymanaged)) { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
} }
@ -1836,7 +1836,7 @@ abstract class CommonObject
$sql .= ' AND te.entity IN ('.getEntity($this->element).')'; $sql .= ' AND te.entity IN ('.getEntity($this->element).')';
} }
} }
if (isset($this->ismultientitymanaged) && ! is_numeric($this->ismultientitymanaged) && $this->element != 'societe') { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged) && $this->element != 'societe') {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
} }
@ -3369,6 +3369,9 @@ abstract class CommonObject
elseif ($objecttype == 'subscription') { elseif ($objecttype == 'subscription') {
$classpath = 'adherents/class'; $module = 'adherent'; $classpath = 'adherents/class'; $module = 'adherent';
} }
elseif ($objecttype == 'contact') {
$module = 'societe';
}
// Set classfile // Set classfile
$classfile = strtolower($subelement); $classname = ucfirst($subelement); $classfile = strtolower($subelement); $classname = ucfirst($subelement);
@ -3391,6 +3394,9 @@ abstract class CommonObject
elseif ($objecttype == 'subscription') { elseif ($objecttype == 'subscription') {
$classfile = 'subscription'; $classname = 'Subscription'; $classfile = 'subscription'; $classname = 'Subscription';
} }
elseif ($objecttype == 'project' || $objecttype == 'projet') {
$classpath = 'projet/class'; $classfile = 'project'; $classname = 'Project';
}
// Here $module, $classfile and $classname are set // Here $module, $classfile and $classname are set
if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) if ($conf->$module->enabled && (($element != $this->element) || $alsosametype))
@ -5625,7 +5631,7 @@ abstract class CommonObject
$form = new Form($this->db); $form = new Form($this->db);
} }
if (! empty($this->fields)) { if (!empty($this->fields)) {
$val = $this->fields[$key]; $val = $this->fields[$key];
} }

View File

@ -293,30 +293,30 @@ class Conf
$rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR; $rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
// Define default dir_output and dir_temp for directories of modules // Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module) foreach ($this->modules as $module)
{ {
//var_dump($module); //var_dump($module);
// For multicompany sharings // For multicompany sharings
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp"); $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
// For backward compatibility // For backward compatibility
$this->$module->dir_output = $rootfordata."/".$module; $this->$module->dir_output = $rootfordata."/".$module;
$this->$module->dir_temp = $rootfortemp."/".$module."/temp"; $this->$module->dir_temp = $rootfortemp."/".$module."/temp";
} }
// External modules storage // External modules storage
if (! empty($this->modules_parts['dir'])) if (!empty($this->modules_parts['dir']))
{ {
foreach($this->modules_parts['dir'] as $module => $dirs) foreach ($this->modules_parts['dir'] as $module => $dirs)
{ {
if (! empty($this->$module->enabled)) if (!empty($this->$module->enabled))
{ {
foreach($dirs as $type => $name) // $type is 'output' or 'temp' foreach ($dirs as $type => $name) // $type is 'output' or 'temp'
{ {
$multidirname = 'multidir_'.$type; $multidirname = 'multidir_'.$type;
$dirname = 'dir_'.$type; $dirname = 'dir_'.$type;
if($type != 'temp') if ($type != 'temp')
{ {
// For multicompany sharings // For multicompany sharings
$this->$module->$multidirname = array($this->entity => $rootfordata."/".$name); $this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
@ -338,90 +338,90 @@ class Conf
} }
// For mycompany storage // For mycompany storage
$this->mycompany->dir_output = $rootfordata."/mycompany"; $this->mycompany->dir_output = $rootfordata."/mycompany";
$this->mycompany->dir_temp = $rootfortemp."/mycompany/temp"; $this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
// For admin storage // For admin storage
$this->admin->dir_output = $rootfordata.'/admin'; $this->admin->dir_output = $rootfordata.'/admin';
$this->admin->dir_temp = $rootfortemp.'/admin/temp'; $this->admin->dir_temp = $rootfortemp.'/admin/temp';
// For user storage // For user storage
$this->user->multidir_output = array($this->entity => $rootfordata."/users"); $this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp"); $this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
// For backward compatibility // For backward compatibility
$this->user->dir_output = $rootforuser."/users"; $this->user->dir_output = $rootforuser."/users";
$this->user->dir_temp = $rootfortemp."/users/temp"; $this->user->dir_temp = $rootfortemp."/users/temp";
// For usergroup storage // For usergroup storage
$this->usergroup->dir_output = $rootforuser."/usergroups"; $this->usergroup->dir_output = $rootforuser."/usergroups";
$this->usergroup->dir_temp = $rootfortemp."/usergroups/temp"; $this->usergroup->dir_temp = $rootfortemp."/usergroups/temp";
// For proposal storage // For proposal storage
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale"); $this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
$this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp"); $this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
// For backward compatibility // For backward compatibility
$this->propal->dir_output = $rootfordata."/propale"; $this->propal->dir_output = $rootfordata."/propale";
$this->propal->dir_temp = $rootfortemp."/propale/temp"; $this->propal->dir_temp = $rootfortemp."/propale/temp";
// For medias storage // For medias storage
$this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
$this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp"); $this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
// Sous module bons d'expedition // Sous module bons d'expedition
$this->expedition_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_EXPEDITION)?$this->global->MAIN_SUBMODULE_EXPEDITION:0); $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0);
// Sous module bons de livraison // Sous module bons de livraison
$this->livraison_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_LIVRAISON)?$this->global->MAIN_SUBMODULE_LIVRAISON:0); $this->livraison_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_LIVRAISON) ? $this->global->MAIN_SUBMODULE_LIVRAISON : 0);
// Module fournisseur // Module fournisseur
if (! empty($this->fournisseur)) if (!empty($this->fournisseur))
{ {
$this->fournisseur->commande=new stdClass(); $this->fournisseur->commande = new stdClass();
$this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande"); $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp"); $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
$this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility $this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
$this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility $this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
$this->fournisseur->facture=new stdClass(); $this->fournisseur->facture = new stdClass();
$this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture"); $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
$this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp"); $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
$this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility $this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
$this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility $this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
$this->supplierproposal=new stdClass(); $this->supplierproposal = new stdClass();
$this->supplierproposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal"); $this->supplierproposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
$this->supplierproposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp"); $this->supplierproposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
$this->supplierproposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility $this->supplierproposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
$this->supplierproposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility $this->supplierproposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
$this->fournisseur->payment=new stdClass(); $this->fournisseur->payment = new stdClass();
$this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment"); $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
$this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp"); $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
$this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility $this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
$this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility $this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
// To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice // To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice
if (! empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties if (!empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties
{ {
if (empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists if (empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists
{ {
$this->supplier_order=new stdClass(); $this->supplier_order = new stdClass();
$this->supplier_order->enabled = 1; $this->supplier_order->enabled = 1;
$this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande"); $this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp"); $this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
$this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility $this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
$this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility $this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
} }
if (empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists if (empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists
{ {
$this->supplier_invoice=new stdClass(); $this->supplier_invoice = new stdClass();
$this->supplier_invoice->enabled = 1; $this->supplier_invoice->enabled = 1;
$this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture"); $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
$this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp"); $this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
$this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility $this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
$this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility $this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
} }
} }
} }
@ -438,22 +438,22 @@ class Conf
$this->service->dir_temp = $rootfortemp."/produit/temp"; $this->service->dir_temp = $rootfortemp."/produit/temp";
// Module productbatch // Module productbatch
$this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot"); $this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot");
$this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/produitlot/temp"); $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/produitlot/temp");
// Module contrat // Module contrat
$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract"); $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
$this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp"); $this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
// For backward compatibility // For backward compatibility
$this->contrat->dir_output = $rootfordata."/contract"; $this->contrat->dir_output = $rootfordata."/contract";
$this->contrat->dir_temp = $rootfortemp."/contract/temp"; $this->contrat->dir_temp = $rootfortemp."/contract/temp";
// Module bank // Module bank
$this->bank->multidir_output = array($this->entity => $rootfordata."/bank"); $this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
$this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp"); $this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
// For backward compatibility // For backward compatibility
$this->bank->dir_output = $rootfordata."/bank"; $this->bank->dir_output = $rootfordata."/bank";
$this->bank->dir_temp = $rootfortemp."/bank/temp"; $this->bank->dir_temp = $rootfortemp."/bank/temp";
// Set some default values // Set some default values
//$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
@ -527,7 +527,7 @@ class Conf
if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy"; if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy";
if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
$this->theme = $this->global->MAIN_THEME; $this->theme = $this->global->MAIN_THEME;
$this->css = "/theme/".$this->theme."/style.css.php"; $this->css = "/theme/".$this->theme."/style.css.php";
// conf->email_from = email pour envoi par dolibarr des mails automatiques // conf->email_from = email pour envoi par dolibarr des mails automatiques
$this->email_from = "robot@example.com"; $this->email_from = "robot@example.com";
@ -681,15 +681,11 @@ class Conf
$this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
} }
if (!isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1;
if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0; if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0;
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
if (! isset($this->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) $this->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN = 1;
// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined. // If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;

View File

@ -504,15 +504,16 @@ class DiscountAbsolute
* @param string $filter Filtre autre * @param string $filter Filtre autre
* @param int $maxvalue Filter on max value for discount * @param int $maxvalue Filter on max value for discount
* @param int $discount_type 0 => customer discount, 1 => supplier discount * @param int $discount_type 0 => customer discount, 1 => supplier discount
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return int <0 if KO, amount otherwise * @return int <0 if KO, amount otherwise
*/ */
public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0) public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0)
{ {
global $conf; global $conf;
dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG);
$sql = "SELECT SUM(rc.amount_ttc) as amount"; $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql .= " WHERE rc.entity = ".$conf->entity; $sql .= " WHERE rc.entity = ".$conf->entity;
$sql .= " AND rc.discount_type=".intval($discount_type); $sql .= " AND rc.discount_type=".intval($discount_type);
@ -535,6 +536,11 @@ class DiscountAbsolute
//print 'zz'.$obj->amount; //print 'zz'.$obj->amount;
//$obj = $this->db->fetch_object($resql); //$obj = $this->db->fetch_object($resql);
//} //}
if ($multicurrency)
{
return $obj->amount_multicurrency;
}
return $obj->amount; return $obj->amount;
} }
return -1; return -1;
@ -604,14 +610,14 @@ class DiscountAbsolute
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
$sql .= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received $sql .= ' AND f.type IN (' . $invoice::TYPE_STANDARD . ', ' . $invoice::TYPE_CREDIT_NOTE . ', ' . $invoice::TYPE_SITUATION . ')'; // Find discount coming from credit note or excess received
} }
elseif ($invoice->element == 'invoice_supplier') elseif ($invoice->element == 'invoice_supplier')
{ {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
$sql .= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess paid $sql .= ' AND f.type IN (' . $invoice::TYPE_STANDARD . ', ' . $invoice::TYPE_CREDIT_NOTE . ')'; // Find discount coming from credit note or excess paid
} }
else else
{ {

View File

@ -90,7 +90,7 @@ class DolEditor
{ {
$content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML.
} }
if ($this->tool == 'fckeditor') /*if ($this->tool == 'fckeditor')
{ {
require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php';
@ -121,7 +121,7 @@ class DolEditor
$this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js'; $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js';
$this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/';
} }
} }*/
// Define some properties // Define some properties
if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) if (in_array($this->tool, array('textarea', 'ckeditor', 'ace')))

View File

@ -951,7 +951,11 @@ class DolGraph
$this->stringtoshow .= '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>'; $this->stringtoshow .= '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
return; return;
} }
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix) ? '' : ' dolgraph'.$this->cssprefix).' center"></div>'."\n";
// Start the div that will contains all the graph
$dolxaxisvertical='';
if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical';
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($dolxaxisvertical)?'':' '.$dolxaxisvertical).(empty($this->cssprefix) ? '' : ' dolgraph'.$this->cssprefix).' center"></div>'."\n";
$this->stringtoshow .= '<script id="'.$tag.'">'."\n"; $this->stringtoshow .= '<script id="'.$tag.'">'."\n";
$this->stringtoshow .= '$(function () {'."\n"; $this->stringtoshow .= '$(function () {'."\n";

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