Merge branch 'develop' of github.com:Dolibarr/dolibarr into 12.0_new_extend_retained_warranty

This commit is contained in:
ATM john 2020-04-14 14:11:12 +02:00
commit b70cd84402
2516 changed files with 49575 additions and 60830 deletions

View File

@ -16,7 +16,7 @@ AdoDb-Date 0.36 Modified BSD License Yes
CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG
EvalMath 1.0 BSD Yes Safe math expressions evaluation EvalMath 1.0 BSD Yes Safe math expressions evaluation
Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package) GeoIP2 0.2.0 LGPL-2.1+ Yes Lib to make geoip convert
Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
@ -38,13 +38,12 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes
JS libraries: JS libraries:
Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea.
Chart 2.9.3 MIT License Yes JS library for graph ChartJS 2.9.3 MIT License Yes JS library for graph
jQuery 3.4.1 MIT License Yes JS library jQuery 3.4.1 MIT License Yes JS library
jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI
jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect
jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups)
jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors
jQuery Flot 0.8.3 MIT License Yes JS library to build graph
jQuery JCrop 0.9.8 GPL and MIT License Yes JS library plugin Crop (to crop images) jQuery JCrop 0.9.8 GPL and MIT License Yes JS library plugin Crop (to crop images)
jQuery Jeditable 1.7.1 GPL and MIT License Yes JS library plugin jeditable (to edit in place) jQuery Jeditable 1.7.1 GPL and MIT License Yes JS library plugin jeditable (to edit in place)
jQuery jNotify 1.1.00 Apache Software License 2.0 Yes JS library plugin jNotify (to use ajax popups) jQuery jNotify 1.1.00 Apache Software License 2.0 Yes JS library plugin jNotify (to use ajax popups)
@ -61,7 +60,7 @@ Image libraries:
Octicons 8.1 MIT Yes Octicons 8.1 MIT Yes
Font libraries: Font libraries:
Fontawesome 5.7.2 Font Awesome Free licence Yes Fontawesome 5.13 Font Awesome Free licence Yes
For licenses compatibility informations: For licenses compatibility informations:

View File

@ -6,6 +6,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 12.0.0 compared to 11.0.0 ***** ***** ChangeLog for 12.0.0 compared to 11.0.0 *****
For Users: For Users:
NEW: Module MO (Manufacturing Order) is available as stable module. NEW: Module MO (Manufacturing Order) is available as stable module.
NEW: Add option MAIN_VIEW_LINE_NUMBER_IN_LIST for some lists.
For Developers or integrators: For Developers or integrators:
* A new way to navigate between pages in list is available. To use it, you must * A new way to navigate between pages in list is available. To use it, you must
@ -24,8 +25,9 @@ Following changes may create regressions for some external modules, but were nec
* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. * 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 * Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced
by a "_" automatically when a reference (with a custom numbering mask that use it) is generated. by a "_" automatically when a reference (with a custom numbering mask that use it) is generated.
* Library jflot (replace with chartjs) and geoip (replaced with geoip2) were removed.
* Hidden constant COMMANDE_VALID_AFTER_CLOSE_PROPAL were renamed into ORDER_VALID_AFTER_CLOSE_PROPAL.
***** ChangeLog for 11.0.3 compared to 11.0.2 ***** ***** ChangeLog for 11.0.3 compared to 11.0.2 *****
FIX: unit price for selected supplier products not set. NaN was used. FIX: unit price for selected supplier products not set. NaN was used.
@ -405,6 +407,77 @@ Following changes may create regressions for some external modules, but were nec
* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core. * The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core.
***** ChangeLog for 10.0.7 compared to 10.0.6 *****
FIX: 10.0 - missing translations for "orders" homepage "orders" box
FIX: 10.0 - status missing from last customer invoices box when using MAIN_STATUS_USES_CSS
FIX: 10.0 - translations for "orders" not loaded in the homepage box
FIX: #10309
FIX: #12875
FIX: #12932
FIX: #12966
FIX: #12973
FIX: #13304
FIX: advanced target emailing sql and ergonomy
FIX: an external user can not approved
FIX: Bad translation for productlot EatBy and SellBy
FIX: better check
FIX: better method to check user rights AND usergroup rights !
FIX: CA by prod list filter
FIX: can be a string or integer
FIX: Check on unicity on prof id was not triggered sometimes
FIX: clone of purchase order
FIX: compatibility with multicompany (avoid duplicate data)
FIX: complex export model loading
FIX: date filter not used if no operator
FIX: date order was -1D and desc with label repetition
FIX: default lang selection when filter
FIX: dom and missing param
FIX: drafts are now implemented for stats
FIX: Error in log for email sending with smtps was not complete
FIX: Extrafield position in export field list must respect "pos" field
FIX: FEC export format
FIX: FEC export have specific name
FIX: fetching account on current entity
FIX: Filenames must not contains non ascii char or we will get non ascii
FIX: fk_type subscription list via api REST
FIX: Force FEC export to txt format
FIX: get remain to pay with rounding decimals
FIX: Invert isSellerInEEC and isBuyerInEEC
FIX: keep assigned users in session when loading projects and tasks
FIX: length, width and height units coherence in product table
FIX: links in products/services index
FIX: Mail smtps truncated if content has a line with single .
FIX: missing array option
FIX: missing global $conf
FIX: missing hook parameter
FIX: Missing Linked objects Fichinter Ref. in PDF formats
FIX: missing "statut" for getNomUrl() function
FIX: multicompany for discount
FIX: must be == and not =
FIX: Problem with column label in subscription list
FIX: regex for include or exclude categories in full arbo
FIX: Remove unexisting link
FIX: remove unused var, $usercancreate can be change by Multicompany
FIX: require category class in extrafield
FIX: round MT in accountancy books
FIX: search with '0'
FIX: send expense report mail in HTML format
FIX: SQL request and phpunit
FIX: substitute lines dates values on doc generator (ODT, ...)
FIX: test on 0 better than isset
FIX: The "automatic bind" was linked EEC to export accountancy code
FIX: thirdparty alias name desappeared if we change country with THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION conf
FIX: timezone must be tzserver and not tzuser as well as on contract card
FIX: typo on ckeck method
FIX: use "usergroup" instead "user"
FIX: Visualization rights correction on last modified contacts box
FIX: Warning on admin/export_files
FIX: We want to be able to import data for extrafields of entity 0 too
FIX: when we filter a list on a view status, we want this filter to be on bookmark that we create
FIX: wrong test
FIX: XSS vulnerability in description of list of audit events.
FIX: z-index for moretabsList with constant MAIN_MAXTABS_IN_CARD
***** ChangeLog for 10.0.6 compared to 10.0.5 ***** ***** ChangeLog for 10.0.6 compared to 10.0.5 *****
FIX Regression of 10.0.5 to create/edit proposals and orders. FIX Regression of 10.0.5 to create/edit proposals and orders.
FIX: #12760 #12763 #12755 #12765 #12751 FIX: #12760 #12763 #12755 #12765 #12751

View File

@ -21,7 +21,7 @@ REM Mysql 5.1+
REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld
REM Mariadb REM Mariadb
REM The mysql_install_db allows to not provide files into mysql dir but does not return to prompt so install hangs REM The mysql_install_db allows to not provide files into mysql dir but does not return to prompt so install hangs
REM .\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql_install_db.exe --datadir=WAMPROOT/bin/mariadb/data --port=WAMPMYSQLPORT --password=WAMPMYSQLNEWPASSWORD >> doliwamp.log 2>>&1 REM .\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql_install_db.exe --datadir=WAMPROOT/bin/mariadb/data --port=WAMPMYSQLPORT --password=WAMPMYSQLXXX >> doliwamp.log 2>>&1
.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql_install_db.exe --datadir=WAMPROOT/bin/mariadb/data --port=WAMPMYSQLPORT >> doliwamp.log 2>>&1 .\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql_install_db.exe --datadir=WAMPROOT/bin/mariadb/data --port=WAMPMYSQLPORT >> doliwamp.log 2>>&1
.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld >> doliwamp.log 2>>&1 .\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld >> doliwamp.log 2>>&1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -222,6 +222,9 @@
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose" /> <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose" />
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration" /> <rule ref="Squiz.Functions.MultiLineFunctionDeclaration" />
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction">
<severity>0</severity>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"> <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties> <properties>
<property name="equalsSpacing" value="1"/> <property name="equalsSpacing" value="1"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 867 B

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
doc/images/dolibarr_logo.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -332,7 +332,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="'.(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="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
print '<br>'; print '<br>';
print '<br>'; print '<br>';
@ -357,7 +357,7 @@ 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 ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</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);
@ -371,7 +371,7 @@ 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 ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); }
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.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";
@ -453,11 +453,11 @@ if ($resql)
if (!empty($arrayfields['aa.reconcilable']['checked'])) { if (!empty($arrayfields['aa.reconcilable']['checked'])) {
print '<td class="center">'; print '<td class="center">';
if (empty($obj->reconcilable)) { if (empty($obj->reconcilable)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable&mode=1">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>'; print '</a>';
} else { } else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable&mode=1">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>'; print '</a>';
} }

View File

@ -237,8 +237,8 @@ if ($action == 'create') {
print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>'; print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>';
// Label short // Label short
print '<tr><td>' . $langs->trans("LabelToShow") . '</td>'; print '<tr><td>'.$langs->trans("LabelToShow").'</td>';
print '<td><input name="labelshort" size="70" value="' . $object->labelshort . '"></td></tr>'; print '<td><input name="labelshort" size="70" value="'.$object->labelshort.'"></td></tr>';
// Account parent // Account parent
print '<tr><td>'.$langs->trans("Accountparent").'</td>'; print '<tr><td>'.$langs->trans("Accountparent").'</td>';
@ -300,8 +300,8 @@ elseif ($id > 0 || $ref) {
print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>'; print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>';
// Label short // Label short
print '<tr><td>' . $langs->trans("LabelToShow") . '</td>'; print '<tr><td>'.$langs->trans("LabelToShow").'</td>';
print '<td><input name="labelshort" size="70" value="' . $object->labelshort . '"</td></tr>'; print '<td><input name="labelshort" size="70" value="'.$object->labelshort.'"</td></tr>';
// Account parent // Account parent
print '<tr><td>'.$langs->trans("Accountparent").'</td>'; print '<tr><td>'.$langs->trans("Accountparent").'</td>';
@ -351,8 +351,8 @@ elseif ($id > 0 || $ref) {
print '<td colspan="2">'.$object->label.'</td></tr>'; print '<td colspan="2">'.$object->label.'</td></tr>';
// Label to show // Label to show
print '<tr><td class="titlefield">' . $langs->trans("LabelToShow") . '</td>'; print '<tr><td class="titlefield">'.$langs->trans("LabelToShow").'</td>';
print '<td colspan="2">' . $object->labelshort . '</td></tr>'; print '<td colspan="2">'.$object->labelshort.'</td></tr>';
// Account parent // Account parent
$accp = new AccountingAccount($db); $accp = new AccountingAccount($db);

View File

@ -23,12 +23,12 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.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 . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta","admin","accountancy")); $langs->loadLangs(array("compta", "admin", "accountancy"));
// Security check // Security check
if (empty($user->rights->accounting->chartofaccount)) { if (empty($user->rights->accounting->chartofaccount)) {
@ -38,7 +38,7 @@ if (empty($user->rights->accounting->chartofaccount)) {
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$list_account_main = array ( $list_account_main = array(
'ACCOUNTING_RESULT_PROFIT', 'ACCOUNTING_RESULT_PROFIT',
'ACCOUNTING_RESULT_LOSS' 'ACCOUNTING_RESULT_LOSS'
); );
@ -52,23 +52,23 @@ if ($action == 'update') {
$defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha');
if (! empty($defaultjournal)) { if (!empty($defaultjournal)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
$error ++; $error++;
} }
} else { } else {
$error ++; $error++;
} }
foreach ($list_account_main as $constname) { foreach ($list_account_main as $constname) {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++; $error++;
} }
} }
if (! $error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -91,8 +91,8 @@ print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_a
print '<span class="opacitymedium">'.$langs->trans("DefaultClosureDesc").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("DefaultClosureDesc").'</span><br>';
print '<br>'; print '<br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">'; print '<form 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="update">'; print '<input type="hidden" name="action" value="update">';
// Define main accounts for closure // Define main accounts for closure
@ -102,14 +102,14 @@ foreach ($list_account_main as $key) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);
$keydesc=$key.'_Desc'; $keydesc = $key.'_Desc';
$htmltext = $langs->trans($keydesc); $htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">'; print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext); print $form->textwithpicto($label, $htmltext);
print '</td>'; print '</td>';
// Value // Value
print '<td>'; // Do not force class=right, or it align also the content of the select box print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -117,15 +117,15 @@ foreach ($list_account_main as $key) {
// Journal // Journal
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="50%">' . $langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL") . '</td>'; print '<td width="50%">'.$langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL").'</td>';
print '<td>'; print '<td>';
$defaultjournal=$conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL; $defaultjournal = $conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL;
print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0); print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0);
print '</td></tr>'; print '</td></tr>';
print "</table>\n"; print "</table>\n";
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>'; print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '</form>'; print '</form>';

View File

@ -274,23 +274,23 @@ if ($action == 'create')
// Label // Label
print '<tr><td class="tdtop">'; print '<tr><td class="tdtop">';
print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print $form->editfieldkey("Label", 'label', $object->label, $object, 1, 'alpha:32');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print $form->editfieldval("Label", 'label', $object->label, $object, 1, 'alpha:32');
print "</td></tr>"; print "</td></tr>";
// Date start // Date start
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, 1, 'datepicker');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, 1, 'datepicker');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, 1, 'datepicker');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, 1, 'datepicker');
print '</td></tr>'; print '</td></tr>';
// Statut // Statut

View File

@ -22,23 +22,23 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.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 . '/core/class/fiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin","compta")); $langs->loadLangs(array("admin", "compta"));
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->fiscalyear->write) if (!$user->rights->accounting->fiscalyear->write)
accessforbidden(); accessforbidden();
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
// View // View
$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Info"); $title = $langs->trans("Fiscalyear")." - ".$langs->trans("Info");
$helpurl = ""; $helpurl = "";
llxHeader("", $title, $helpurl); llxHeader("", $title, $helpurl);

View File

@ -71,9 +71,9 @@ if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.doc_date,t.rowid"; if ($sortfield == "") $sortfield = "t.doc_date,t.rowid";
if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) { if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) {
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql.= $db->plimit(1); $sql .= $db->plimit(1);
$res = $db->query($sql); $res = $db->query($sql);
if ($res->num_rows > 0) { if ($res->num_rows > 0) {
@ -220,15 +220,15 @@ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$num=count($object->lines); $num = count($object->lines);
if ($action == 'delmouv') { if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm; print $formconfirm;
} }
if ($action == 'delbookkeepingyear') { if ($action == 'delbookkeepingyear') {
$form_question = array (); $form_question = array();
$delyear = GETPOST('delyear'); $delyear = GETPOST('delyear');
if (empty($delyear)) { if (empty($delyear)) {
@ -249,7 +249,7 @@ if ($action == 'delbookkeepingyear') {
} }
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -259,11 +259,11 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create');
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);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit);
@ -335,7 +335,7 @@ while ($i < min($num, $limit))
//if (empty($accountg)) $accountg = '-'; //if (empty($accountg)) $accountg = '-';
// Is it a break ? // Is it a break ?
if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
// Affiche un Sous-Total par compte comptable // Affiche un Sous-Total par compte comptable
if (isset($displayed_account_number)) { if (isset($displayed_account_number)) {
print '<tr class="liste_total"><td class="right" colspan="5">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td>'; print '<tr class="liste_total"><td class="right" colspan="5">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td>';
@ -348,7 +348,7 @@ while ($i < min($num, $limit))
$colspan = 9; $colspan = 9;
print "<tr>"; print "<tr>";
print '<td colspan="'.$colspan.'" style="font-weight:bold; border-bottom: 1pt solid black;">'; print '<td colspan="'.$colspan.'" style="font-weight:bold; border-bottom: 1pt solid black;">';
if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte);
else print '<span class="error">'.$langs->trans("Unknown").'</span>'; else print '<span class="error">'.$langs->trans("Unknown").'</span>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -373,20 +373,20 @@ while ($i < min($num, $limit))
// Affiche un lien vers la facture client/fournisseur // Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>' . $line->label_operation . '</td>' : '<td>' . $line->label_operation . '<br><span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')</span></td>'; print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>';
print '<td class="nowrap right">' . ($line->debit ? price($line->debit) :''). '</td>'; print '<td class="nowrap right">'.($line->debit ? price($line->debit) : '').'</td>';
print '<td class="nowrap right">' . ($line->credit ? price($line->credit) : '') . '</td>'; print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>';
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $line->code_journal); $result = $accountingjournal->fetch('', $line->code_journal);
$journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
print '<td class="center">' . $journaltoshow . '</td>'; print '<td class="center">'.$journaltoshow.'</td>';
print '<td class="center">'; print '<td class="center">';
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;'; print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.'">'.img_edit().'</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.'">'.img_delete().'</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -27,22 +27,22 @@
* \brief Tab to manage customer lettering * \brief Tab to manage customer lettering
*/ */
require '../../main.inc.php'; require '../../main.inc.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 . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.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 . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta","accountancy")); $langs->loadLangs(array("compta", "accountancy"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
@ -139,15 +139,15 @@ dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'com
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
dol_fiche_end(); dol_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )"; $sql .= " WHERE (bk.subledger_account = '".$object->code_compta."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER."' )";
/* /*
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
@ -155,7 +155,7 @@ if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
} }
*/ */
$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')'; $sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$debit = 0; $debit = 0;
@ -186,8 +186,8 @@ if (!$resql) {
exit(); exit();
} }
$param=''; $param = '';
$param.="&socid=".urlencode($socid); $param .= "&socid=".urlencode($socid);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -195,10 +195,10 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB
if ($resql) { if ($resql) {
$i = 0; $i = 0;
$param="&socid=".$socid; $param = "&socid=".$socid;
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="' . newToken() . '">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="socid" value="' . $object->id . '">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
$letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>'; $letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
@ -250,33 +250,33 @@ if ($resql) {
$solde = 0; $solde = 0;
$tmp = ''; $tmp = '';
while ( $obj = $db->fetch_object($resql) ) { while ($obj = $db->fetch_object($resql)) {
if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code;
/*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
//print '<td>' . $obj->doc_type . '</td>' . "\n"; //print '<td>' . $obj->doc_type . '</td>' . "\n";
print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>'.$obj->doc_ref.'</td>';
print '<td>' . $obj->label_compte . '</td>'; print '<td>'.$obj->label_compte.'</td>';
print '<td class="nowrap right">' . price($obj->debit) . '</td>'; print '<td class="nowrap right">'.price($obj->debit).'</td>';
print '<td class="nowrap right">' . price($obj->credit) . '</td>'; print '<td class="nowrap right">'.price($obj->credit).'</td>';
print '<td class="nowrap right">' . price(round($solde, 2)) . '</td>'; print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
// Journal // Journal
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $obj->code_journal); $result = $accountingjournal->fetch('', $obj->code_journal);
$journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
print '<td class="center">' . $journaltoshow . '</td>'; print '<td class="center">'.$journaltoshow.'</td>';
if (empty($obj->lettering_code)) { if (empty($obj->lettering_code)) {
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>'; print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $obj->piece_num . '">'; print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
print img_edit(); print img_edit();
print '</a></td>' . "\n"; print '</a></td>'."\n";
} else { } else {
print '<td class="center">' . $obj->lettering_code . '</td>'; print '<td class="center">'.$obj->lettering_code.'</td>';
print '<td></td>'; print '<td></td>';
} }
@ -284,16 +284,16 @@ if ($resql) {
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>'."\n";
print '<td class="nowrap right"><strong>' . price($debit) . '</strong></td>'; print '<td class="nowrap right"><strong>'.price($debit).'</strong></td>';
print '<td class="nowrap right"><strong>' . price($credit) . '</strong></td>'; print '<td class="nowrap right"><strong>'.price($credit).'</strong></td>';
print '<td colspan="4"></td>'; print '<td colspan="4"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>'."\n";
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '<td class="nowrap right"><strong>' . price($credit - $debit) . '</strong></td>'; print '<td class="nowrap right"><strong>'.price($credit - $debit).'</strong></td>';
print '<td colspan="6"></td>'; print '<td colspan="6"></td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -26,22 +26,22 @@
* \brief Tab to setup lettering * \brief Tab to setup lettering
*/ */
require '../../main.inc.php'; require '../../main.inc.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 . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.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 . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta","accountancy")); $langs->loadLangs(array("compta", "accountancy"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
@ -67,7 +67,7 @@ $search_doc_ref = GETPOST("search_doc_ref",'alpha');
$lettering = GETPOST('lettering', 'alpha'); $lettering = GETPOST('lettering', 'alpha');
if (!empty($lettering)) { if (!empty($lettering)) {
$action=$lettering; $action = $lettering;
} }
/* /*
@ -138,20 +138,20 @@ dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'com
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
dol_fiche_end(); dol_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )"; $sql .= " WHERE (bk.subledger_account = '".$object->code_compta_fournisseur."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER."' )";
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
$sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )"; $sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )";
} }
$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')'; $sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
$sql.= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$debit = 0; $debit = 0;
$credit = 0; $credit = 0;
@ -173,17 +173,17 @@ while ($obj = $db->fetch_object($resql)) {
$solde += ($obj->credit - $obj->debit); $solde += ($obj->credit - $obj->debit);
} }
$sql.= $db->plimit($limit+1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG); dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) { if (!$resql) {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$param=''; $param = '';
$param.="&socid=".urlencode($socid); $param .= "&socid=".urlencode($socid);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -193,10 +193,10 @@ if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$param="&socid=".$socid; $param = "&socid=".$socid;
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid=' . $object->id . '" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="' . newToken() . '">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="socid" value="' . $object->id . '">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
$letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>'; $letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
@ -254,26 +254,26 @@ if ($resql) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
//print '<td>' . $obj->doc_type . '</td>' . "\n"; //print '<td>' . $obj->doc_type . '</td>' . "\n";
print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>'.$obj->doc_ref.'</td>';
print '<td>' . $obj->label_compte . '</td>'; print '<td>'.$obj->label_compte.'</td>';
print '<td class="nowrap right">' . price($obj->debit) . '</td>'; print '<td class="nowrap right">'.price($obj->debit).'</td>';
print '<td class="nowrap right">' . price($obj->credit) . '</td>'; print '<td class="nowrap right">'.price($obj->credit).'</td>';
print '<td class="nowrap right">' . price(round($solde, 2)) . '</td>'; print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
// Journal // Journal
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $obj->code_journal); $result = $accountingjournal->fetch('', $obj->code_journal);
$journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
print '<td class="center">' . $journaltoshow . '</td>'; print '<td class="center">'.$journaltoshow.'</td>';
if (empty($obj->lettering_code) && empty($obj->date_validated) ) { if (empty($obj->lettering_code) && empty($obj->date_validated)) {
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>'; print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $obj->piece_num . '">'; print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
print img_edit(); print img_edit();
print '</a></td>' . "\n"; print '</a></td>'."\n";
} else { } else {
print '<td class="center">' . $obj->lettering_code . '</td>'; print '<td class="center">'.$obj->lettering_code.'</td>';
print '<td></td>'; print '<td></td>';
} }
@ -281,16 +281,16 @@ if ($resql) {
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>'."\n";
print '<td class="nowrap right"><strong>' . price($debit) . '</strong></td>'; print '<td class="nowrap right"><strong>'.price($debit).'</strong></td>';
print '<td class="nowrap right"><strong>' . price($credit) . '</strong></td>'; print '<td class="nowrap right"><strong>'.price($credit).'</strong></td>';
print '<td colspan="6"></td>'; print '<td colspan="6"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>'."\n";
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '<td class="nowrap right"><strong>' . price($credit - $debit) . '</strong></td>'; print '<td class="nowrap right"><strong>'.price($credit - $debit).'</strong></td>';
print '<td colspan="4"></td>'; print '<td colspan="4"></td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -24,7 +24,7 @@
*/ */
// Class // Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
/** /**
* Class to manage categories of an accounting account * Class to manage categories of an accounting account
@ -49,12 +49,12 @@ class AccountancyCategory // extends CommonObject
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element='c_accounting_category'; public $element = 'c_accounting_category';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='c_accounting_category'; public $table_element = 'c_accounting_category';
/** /**
* @var int ID * @var int ID
@ -150,15 +150,15 @@ class AccountancyCategory // extends CommonObject
public function create($user, $notrigger = 0) public function create($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->code)) $this->code=trim($this->code); if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->label)) $this->label=trim($this->label); if (isset($this->label)) $this->label = trim($this->label);
if (isset($this->range_account)) $this->range_account=trim($this->range_account); if (isset($this->range_account)) $this->range_account = trim($this->range_account);
if (isset($this->sens)) $this->sens = (int) $this->sens; if (isset($this->sens)) $this->sens = (int) $this->sens;
if (isset($this->category_type)) $this->category_type = (int) $this->category_type; if (isset($this->category_type)) $this->category_type = (int) $this->category_type;
if (isset($this->formula)) $this->formula=trim($this->formula); if (isset($this->formula)) $this->formula = trim($this->formula);
if (isset($this->position)) $this->position = (int) $this->position; if (isset($this->position)) $this->position = (int) $this->position;
if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country;
if (isset($this->active)) $this->active = (int) $this->active; if (isset($this->active)) $this->active = (int) $this->active;
@ -168,65 +168,47 @@ class AccountancyCategory // extends CommonObject
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category(";
if ($this->rowid > 0) $sql.= "rowid, "; if ($this->rowid > 0) $sql .= "rowid, ";
$sql.= "code, "; $sql .= "code, ";
$sql.= "label, "; $sql .= "label, ";
$sql.= "range_account, "; $sql .= "range_account, ";
$sql.= "sens, "; $sql .= "sens, ";
$sql.= "category_type, "; $sql .= "category_type, ";
$sql.= "formula, "; $sql .= "formula, ";
$sql.= "position, "; $sql .= "position, ";
$sql.= "fk_country, "; $sql .= "fk_country, ";
$sql.= "active, "; $sql .= "active, ";
$sql.= "entity"; $sql .= "entity";
$sql.= ") VALUES ("; $sql .= ") VALUES (";
if ($this->rowid > 0) $sql.= " ".$this->rowid.","; if ($this->rowid > 0) $sql .= " ".$this->rowid.",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").",";
$sql.= " ".(! isset($this->range_account)?'NULL':"'".$this->db->escape($this->range_account)."'").","; $sql .= " ".(!isset($this->range_account) ? 'NULL' : "'".$this->db->escape($this->range_account)."'").",";
$sql.= " ".(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").","; $sql .= " ".(!isset($this->sens) ? 'NULL' : "'".$this->db->escape($this->sens)."'").",";
$sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->db->escape($this->category_type)."'").","; $sql .= " ".(!isset($this->category_type) ? 'NULL' : "'".$this->db->escape($this->category_type)."'").",";
$sql.= " ".(! isset($this->formula)?'NULL':"'".$this->db->escape($this->formula)."'").","; $sql .= " ".(!isset($this->formula) ? 'NULL' : "'".$this->db->escape($this->formula)."'").",";
$sql.= " ".(! isset($this->position)?'NULL':$this->db->escape($this->position)).","; $sql .= " ".(!isset($this->position) ? 'NULL' : $this->db->escape($this->position)).",";
$sql.= " ".(! isset($this->fk_country)?'NULL':$this->db->escape($this->fk_country)).","; $sql .= " ".(!isset($this->fk_country) ? 'NULL' : $this->db->escape($this->fk_country)).",";
$sql.= " ".(! isset($this->active)?'NULL':$this->db->escape($this->active)); $sql .= " ".(!isset($this->active) ? 'NULL' : $this->db->escape($this->active));
$sql.= ", ".$conf->entity; $sql .= ", ".$conf->entity;
$sql.= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_accounting_category");
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//if (! $notrigger)
//{
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
//}
}
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@ -247,27 +229,27 @@ class AccountancyCategory // extends CommonObject
public function fetch($id, $code = '', $label = '') public function fetch($id, $code = '', $label = '')
{ {
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql .= " t.rowid,";
$sql.= " t.code,"; $sql .= " t.code,";
$sql.= " t.label,"; $sql .= " t.label,";
$sql.= " t.range_account,"; $sql .= " t.range_account,";
$sql.= " t.sens,"; $sql .= " t.sens,";
$sql.= " t.category_type,"; $sql .= " t.category_type,";
$sql.= " t.formula,"; $sql .= " t.formula,";
$sql.= " t.position,"; $sql .= " t.position,";
$sql.= " t.fk_country,"; $sql .= " t.fk_country,";
$sql.= " t.active"; $sql .= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
if ($id) $sql.= " WHERE t.rowid = ".$id; if ($id) $sql .= " WHERE t.rowid = ".$id;
else else
{ {
$sql.= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid $sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid
if ($code) $sql.= " AND t.code = '".$this->db->escape($code)."'"; if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'";
elseif ($label) $sql.= " AND t.label = '".$this->db->escape($label)."'"; elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'";
} }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
@ -291,7 +273,7 @@ class AccountancyCategory // extends CommonObject
} }
else else
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
} }
@ -307,15 +289,15 @@ class AccountancyCategory // extends CommonObject
public function update($user = null, $notrigger = 0) public function update($user = null, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->code)) $this->code=trim($this->code); if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->label)) $this->label=trim($this->label); if (isset($this->label)) $this->label = trim($this->label);
if (isset($this->range_account)) $this->range_account=trim($this->range_account); if (isset($this->range_account)) $this->range_account = trim($this->range_account);
if (isset($this->sens)) $this->sens = (int) $this->sens; if (isset($this->sens)) $this->sens = (int) $this->sens;
if (isset($this->category_type)) $this->category_type = (int) $this->category_type; if (isset($this->category_type)) $this->category_type = (int) $this->category_type;
if (isset($this->formula)) $this->formula=trim($this->formula); if (isset($this->formula)) $this->formula = trim($this->formula);
if (isset($this->position)) $this->position = (int) $this->position; if (isset($this->position)) $this->position = (int) $this->position;
if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country;
if (isset($this->active)) $this->active = (int) $this->active; if (isset($this->active)) $this->active = (int) $this->active;
@ -326,48 +308,33 @@ class AccountancyCategory // extends CommonObject
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET";
$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
$sql.= " range_account=".(isset($this->range_account)?"'".$this->db->escape($this->range_account)."'":"null").","; $sql .= " range_account=".(isset($this->range_account) ? "'".$this->db->escape($this->range_account)."'" : "null").",";
$sql.= " sens=".(isset($this->sens)?$this->sens:"null").","; $sql .= " sens=".(isset($this->sens) ? $this->sens : "null").",";
$sql.= " category_type=".(isset($this->category_type)?$this->category_type:"null").","; $sql .= " category_type=".(isset($this->category_type) ? $this->category_type : "null").",";
$sql.= " formula=".(isset($this->formula)?"'".$this->db->escape($this->formula)."'":"null").","; $sql .= " formula=".(isset($this->formula) ? "'".$this->db->escape($this->formula)."'" : "null").",";
$sql.= " position=".(isset($this->position)?$this->position:"null").","; $sql .= " position=".(isset($this->position) ? $this->position : "null").",";
$sql.= " fk_country=".(isset($this->fk_country)?$this->fk_country:"null").","; $sql .= " fk_country=".(isset($this->fk_country) ? $this->fk_country : "null").",";
$sql.= " active=".(isset($this->active)?$this->active:"null").""; $sql .= " active=".(isset($this->active) ? $this->active : "null")."";
$sql.= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
//if (! $error)
//{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//if (! $notrigger)
//{
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
//}
//}
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@ -387,42 +354,27 @@ class AccountancyCategory // extends CommonObject
public function delete($user, $notrigger = 0) public function delete($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category";
$sql.= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
//if (! $error)
//{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//if (! $notrigger)
//{
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
//}
//}
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
foreach($this->errors as $errmsg) foreach ($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1 * $error;
} }
else else
{ {
@ -442,28 +394,28 @@ class AccountancyCategory // extends CommonObject
{ {
global $conf; global $conf;
$sql = "SELECT t.rowid, t.account_number, t.label"; $sql = "SELECT t.rowid, t.account_number, t.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = " . $id; $sql .= " WHERE t.fk_accounting_category = ".$id;
$sql .= " AND t.entity = " . $conf->entity; $sql .= " AND t.entity = ".$conf->entity;
$this->lines_display = array(); $this->lines_display = array();
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG); dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) { if ($num) {
while ( $obj = $this->db->fetch_object($resql) ) { while ($obj = $this->db->fetch_object($resql)) {
$this->lines_display[] = $obj; $this->lines_display[] = $obj;
} }
} }
return $num; return $num;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
return - 1; return -1;
} }
} }
@ -479,40 +431,40 @@ class AccountancyCategory // extends CommonObject
global $conf; global $conf;
$sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
$sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " WHERE t.numero_compte NOT IN (";
$sql .= " SELECT t.account_number"; $sql .= " SELECT t.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")"; $sql .= " WHERE t.fk_accounting_category = ".$id." AND t.entity = ".$conf->entity.")";
$sql .= " AND t.numero_compte IN ("; $sql .= " AND t.numero_compte IN (";
$sql .= " SELECT DISTINCT aa.account_number"; $sql .= " SELECT DISTINCT aa.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = " . $conf->entity . ")"; $sql .= " AND aa.entity = ".$conf->entity.")";
$sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref";
$sql .= " ORDER BY t.numero_compte"; $sql .= " ORDER BY t.numero_compte";
$this->lines_CptBk = array (); $this->lines_CptBk = array();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) { if ($num) {
while ( $obj = $this->db->fetch_object($resql) ) { while ($obj = $this->db->fetch_object($resql)) {
$this->lines_cptbk[] = $obj; $this->lines_cptbk[] = $obj;
} }
} }
return $num; return $num;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
return - 1; return -1;
} }
} }
@ -528,34 +480,34 @@ class AccountancyCategory // extends CommonObject
global $conf; global $conf;
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = " . $conf->entity; $sql .= " AND aa.entity = ".$conf->entity;
$sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " GROUP BY aa.account_number, aa.label";
$sql .= " ORDER BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label";
$this->lines_CptBk = array (); $this->lines_CptBk = array();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) { if ($num) {
while ( $obj = $this->db->fetch_object($resql) ) { while ($obj = $this->db->fetch_object($resql)) {
$this->lines_cptbk[] = $obj; $this->lines_cptbk[] = $obj;
} }
} }
return $num; return $num;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
return - 1; return -1;
} }
} }
@ -575,42 +527,42 @@ class AccountancyCategory // extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$sql = "SELECT aa.rowid, aa.account_number"; $sql = "SELECT aa.rowid, aa.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = " . $conf->entity; $sql .= " AND aa.entity = ".$conf->entity;
$sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql
$this->db->begin(); $this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (!$resql) {
$error ++; $error++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
$accountincptsadded=array(); $accountincptsadded = array();
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$account_number_formated=length_accountg($obj->account_number); $account_number_formated = length_accountg($obj->account_number);
if (! empty($accountincptsadded[$account_number_formated])) continue; if (!empty($accountincptsadded[$account_number_formated])) continue;
if (array_key_exists($account_number_formated, $cpts)) if (array_key_exists($account_number_formated, $cpts))
{ {
$accountincptsadded[$account_number_formated]=1; $accountincptsadded[$account_number_formated] = 1;
// We found an account number that is in list $cpts of account to add // We found an account number that is in list $cpts of account to add
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
$sql .= " SET fk_accounting_category=" . $id_cat; $sql .= " SET fk_accounting_category=".$id_cat;
$sql .= " WHERE rowid=".$obj->rowid; $sql .= " WHERE rowid=".$obj->rowid;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resqlupdate = $this->db->query($sql); $resqlupdate = $this->db->query($sql);
if (! $resqlupdate) { if (!$resqlupdate) {
$error ++; $error++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
} }
} }
@ -618,12 +570,12 @@ class AccountancyCategory // extends CommonObject
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return - 1 * $error; return -1 * $error;
} else { } else {
$this->db->commit(); $this->db->commit();
@ -642,27 +594,27 @@ class AccountancyCategory // extends CommonObject
{ {
$error = 0; $error = 0;
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " SET fk_accounting_category= 0"; $sql .= " SET fk_accounting_category= 0";
$sql .= " WHERE aa.rowid= " . $cpt_id; $sql .= " WHERE aa.rowid= ".$cpt_id;
$this->db->begin(); $this->db->begin();
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG); dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (!$resql) {
$error ++; $error++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return - 1 * $error; return -1 * $error;
} else { } else {
$this->db->commit(); $this->db->commit();
@ -685,14 +637,14 @@ class AccountancyCategory // extends CommonObject
} }
$sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat";
$sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid ";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql .= " WHERE c.active = 1"; $sql .= " WHERE c.active = 1";
$sql .= " AND c.entity = " . $conf->entity; $sql .= " AND c.entity = ".$conf->entity;
$sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)";
$sql .= " AND cat.rowid = t.fk_accounting_category"; $sql .= " AND cat.rowid = t.fk_accounting_category";
$sql .= " AND t.entity = " . $conf->entity; $sql .= " AND t.entity = ".$conf->entity;
$sql .= " ORDER BY cat.position ASC"; $sql .= " ORDER BY cat.position ASC";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -700,11 +652,11 @@ class AccountancyCategory // extends CommonObject
$i = 0; $i = 0;
$obj = ''; $obj = '';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$data = array (); $data = array();
if ($num) { if ($num) {
while ( $obj = $this->db->fetch_object($resql) ) { while ($obj = $this->db->fetch_object($resql)) {
$name_cat = $obj->name_cat; $name_cat = $obj->name_cat;
$data[$name_cat][$i] = array ( $data[$name_cat][$i] = array(
'id' => $obj->rowid, 'id' => $obj->rowid,
'code' => $obj->code, 'code' => $obj->code,
'position' => $obj->position, 'position' => $obj->position,
@ -712,13 +664,13 @@ class AccountancyCategory // extends CommonObject
'account_label' => $obj->account_label, 'account_label' => $obj->account_label,
'sens' => $obj->sens 'sens' => $obj->sens
); );
$i ++; $i++;
} }
} }
return $data; return $data;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -744,34 +696,34 @@ class AccountancyCategory // extends CommonObject
$this->sdcpermonth = array(); $this->sdcpermonth = array();
$sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit";
if (is_array($cpt)) $sql.=", t.numero_compte as accountancy_account"; if (is_array($cpt)) $sql .= ", t.numero_compte as accountancy_account";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
//if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date'; //if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date';
$sql .= " WHERE t.entity = ".$conf->entity; $sql .= " WHERE t.entity = ".$conf->entity;
if (is_array($cpt)) if (is_array($cpt))
{ {
$listofaccount=''; $listofaccount = '';
foreach($cpt as $cptcursor) foreach ($cpt as $cptcursor)
{ {
if ($listofaccount) $listofaccount.=","; if ($listofaccount) $listofaccount .= ",";
$listofaccount.="'".$cptcursor."'"; $listofaccount .= "'".$cptcursor."'";
} }
$sql .= " AND t.numero_compte IN (" .$listofaccount. ")"; $sql .= " AND t.numero_compte IN (".$listofaccount.")";
} }
else else
{ {
$sql .= " AND t.numero_compte = '" . $this->db->escape($cpt) . "'"; $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'";
} }
if (! empty($date_start) && ! empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end
$sql .= " AND (t.doc_date BETWEEN '".$this->db->idate($date_start)."' AND '".$this->db->idate($date_end)."')"; $sql .= " AND (t.doc_date BETWEEN '".$this->db->idate($date_start)."' AND '".$this->db->idate($date_end)."')";
if (! empty($month) && ! empty($year)) { if (!empty($month) && !empty($year)) {
$sql .= " AND (t.doc_date BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."')"; $sql .= " AND (t.doc_date BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."')";
} }
if ($thirdparty_code != 'nofilter') if ($thirdparty_code != 'nofilter')
{ {
$sql .= " AND t.thirdparty_code = '".$this->db->escape($thirdparty_code)."'"; $sql .= " AND t.thirdparty_code = '".$this->db->escape($thirdparty_code)."'";
} }
if (is_array($cpt)) $sql.=" GROUP BY t.numero_compte"; if (is_array($cpt)) $sql .= " GROUP BY t.numero_compte";
//print $sql; //print $sql;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -793,9 +745,9 @@ class AccountancyCategory // extends CommonObject
} }
return $num; return $num;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -816,10 +768,10 @@ class AccountancyCategory // extends CommonObject
} }
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type, c.sens"; $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type, c.sens";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql .= " WHERE c.active = 1"; $sql .= " WHERE c.active = 1";
$sql .= " AND c.entity = " . $conf->entity; $sql .= " AND c.entity = ".$conf->entity;
if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; if ($categorytype >= 0) $sql .= " AND c.category_type = 1";
$sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)";
$sql .= " ORDER BY c.position ASC"; $sql .= " ORDER BY c.position ASC";
@ -828,12 +780,12 @@ class AccountancyCategory // extends CommonObject
$i = 0; $i = 0;
$obj = ''; $obj = '';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$data = array (); $data = array();
if ($num) { if ($num) {
while ( $i < $num ) { while ($i < $num) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$data[] = array ( $data[] = array(
'rowid' => $obj->rowid, 'rowid' => $obj->rowid,
'code' => $obj->code, 'code' => $obj->code,
'label' => $obj->label, 'label' => $obj->label,
@ -847,11 +799,11 @@ class AccountancyCategory // extends CommonObject
} }
return $data; return $data;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR);
return - 1; return -1;
} }
} }
@ -874,20 +826,20 @@ class AccountancyCategory // extends CommonObject
exit(); exit();
} }
if (! empty($cat_id)) if (!empty($cat_id))
{ {
$sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = ".$cat_id; $sql .= " WHERE t.fk_accounting_category = ".$cat_id;
$sql .= " AND t.entity = " . $conf->entity; $sql .= " AND t.entity = ".$conf->entity;
$sql .= " ORDER BY t.account_number"; $sql .= " ORDER BY t.account_number";
} }
else else
{ {
$sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE ".$predefinedgroupwhere; $sql .= " WHERE ".$predefinedgroupwhere;
$sql .= " AND t.entity = " . $conf->entity; $sql .= " AND t.entity = ".$conf->entity;
$sql .= " ORDER BY t.account_number"; $sql .= " ORDER BY t.account_number";
} }
//echo $sql; //echo $sql;
@ -901,7 +853,7 @@ class AccountancyCategory // extends CommonObject
if ($num) { if ($num) {
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$data[] = array ( $data[] = array(
'id' => $obj->rowid, 'id' => $obj->rowid,
'account_number' => $obj->account_number, 'account_number' => $obj->account_number,
'account_label' => $obj->account_label, 'account_label' => $obj->account_label,
@ -911,8 +863,8 @@ class AccountancyCategory // extends CommonObject
} }
return $data; return $data;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
return -1; return -1;
} }

View File

@ -1079,28 +1079,28 @@ class AccountancyExport
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
// TYPE C // TYPE C
if($last_codeinvoice != $line->doc_ref){ if ($last_codeinvoice != $line->doc_ref) {
//recherche societe en fonction de son code client //recherche societe en fonction de son code client
$sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code ."'"; $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code."'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if($resql && $this->db->num_rows($resql)>0) if ($resql && $this->db->num_rows($resql) > 0)
{ {
$soc = $this->db->fetch_object($resql); $soc = $this->db->fetch_object($resql);
$address=array('','',''); $address = array('', '', '');
if (strpos($soc->address, "\n")!==false) { if (strpos($soc->address, "\n") !== false) {
$address = explode("\n", $soc->address); $address = explode("\n", $soc->address);
if (is_array($address) && count($address)>0) { if (is_array($address) && count($address) > 0) {
foreach($address as $key=>$data) { foreach ($address as $key=>$data) {
$address[$key]=str_replace(array("\t", "\n", "\r"), "", $data); $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
$address[$key]=dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
} }
} }
} else { } else {
$address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
$address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
$address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
} }
$type_enregistrement = 'C'; $type_enregistrement = 'C';
@ -1254,7 +1254,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

@ -98,15 +98,15 @@ class AccountancySystem
if ($rowid > 0 || $ref) if ($rowid > 0 || $ref)
{ {
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " a.rowid = '" . $rowid . "'"; $sql .= " a.rowid = '".$rowid."'";
} elseif ($ref) { } elseif ($ref) {
$sql .= " a.pcg_version = '" . $this->db->escape($ref) . "'"; $sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
} }
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -124,11 +124,11 @@ class AccountancySystem
return 0; return 0;
} }
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
} }
return - 1; return -1;
} }
@ -142,14 +142,14 @@ class AccountancySystem
{ {
$now = dol_now(); $now = dol_now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
$sql .= " (date_creation, fk_user_author, numero, label)"; $sql .= " (date_creation, fk_user_author, numero, label)";
$sql .= " VALUES ('" . $this->db->idate($now) . "'," . $user->id . ",'" . $this->db->escape($this->numero) . "','" . $this->db->escape($this->label) . "')"; $sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')";
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system");
if ($id > 0) { if ($id > 0) {
$this->rowid = $id; $this->rowid = $id;

View File

@ -34,12 +34,12 @@ class AccountingAccount extends CommonObject
/** /**
* @var string Name of element * @var string Name of element
*/ */
public $element='accounting_account'; public $element = 'accounting_account';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='accounting_account'; public $table_element = 'accounting_account';
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@ -150,7 +150,7 @@ class AccountingAccount extends CommonObject
global $conf; global $conf;
$this->db = $db; $this->db = $db;
$this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method
} }
/** /**
@ -169,23 +169,23 @@ class AccountingAccount extends CommonObject
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.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable"; $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, a.reconcilable";
$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";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " a.rowid = " . (int) $rowid; $sql .= " a.rowid = ".(int) $rowid;
} elseif ($account_number) { } elseif ($account_number) {
$sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; $sql .= " a.account_number = '".$this->db->escape($account_number)."'";
$sql .= " AND a.entity = ".$conf->entity; $sql .= " AND a.entity = ".$conf->entity;
} }
if (! empty($limittocurrentchart)) { if (!empty($limittocurrentchart)) {
$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')';
} }
if (! empty($limittoachartaccount)) { if (!empty($limittoachartaccount)) {
$sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'";
} }
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -215,8 +215,8 @@ class AccountingAccount extends CommonObject
return 0; return 0;
} }
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
} }
return -1; return -1;
@ -255,7 +255,7 @@ class AccountingAccount extends CommonObject
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_account(";
$sql .= "datec"; $sql .= "datec";
$sql .= ", entity"; $sql .= ", entity";
$sql .= ", fk_pcg_version"; $sql .= ", fk_pcg_version";
@ -269,50 +269,48 @@ class AccountingAccount extends CommonObject
$sql .= ", active"; $sql .= ", active";
$sql .= ", reconcilable"; $sql .= ", reconcilable";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " '" . $this->db->idate($now) . "'"; $sql .= " '".$this->db->idate($now)."'";
$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->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)."'");
$sql .= ", " . (empty($this->labelshort) ? "''" : "'" . $this->db->escape($this->labelshort) . "'"); $sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'");
$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category); $sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= ", " . $user->id; $sql .= ", ".$user->id;
$sql .= ", " . (int) $this->active; $sql .= ", ".(int) $this->active;
$sql .= ", " . (int) $this->reconcilable; $sql .= ", ".(int) $this->reconcilable;
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
if (! $error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_account");
// if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action to call a trigger.
//if (! $error && ! $notrigger) {
// // Call triggers // // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
// $interface=new Interfaces($this->db); // if ($result < 0) $error++;
// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers // // End call triggers
// } //}
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1 * $error; return -1 * $error;
@ -338,20 +336,20 @@ class AccountingAccount extends CommonObject
$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 .= " , 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)."'" : "''");
$sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''"); $sql .= " , labelshort = ".($this->labelshort ? "'".$this->db->escape($this->labelshort)."'" : "''");
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category); $sql .= " , fk_accounting_category = ".(empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= " , fk_user_modif = " . $user->id; $sql .= " , fk_user_modif = ".$user->id;
$sql .= " , active = " . (int) $this->active; $sql .= " , active = ".(int) $this->active;
$sql .= " , reconcilable = " . (int) $this->reconcilable; $sql .= " , reconcilable = ".(int) $this->reconcilable;
$sql .= " WHERE rowid = " . $this->id; $sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$this->db->commit(); $this->db->commit();
@ -359,7 +357,7 @@ class AccountingAccount extends CommonObject
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return - 1; return -1;
} }
} }
@ -372,13 +370,13 @@ class AccountingAccount extends CommonObject
{ {
global $langs; global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet";
$sql.= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= " WHERE fk_code_ventilation=".$this->id.")";
$sql.= "UNION"; $sql .= "UNION";
$sql.= " (SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facture_fourn_det";
$sql.= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= " WHERE fk_code_ventilation=".$this->id.")";
dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::checkUsage sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -391,7 +389,7 @@ class AccountingAccount extends CommonObject
} }
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return - 1; return -1;
} }
} }
@ -411,46 +409,32 @@ class AccountingAccount extends CommonObject
if ($result > 0) { if ($result > 0) {
$this->db->begin(); $this->db->begin();
// if (! $error) { if (!$error) {
// if (! $notrigger) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_account";
// Uncomment this and change MYOBJECT to your own tag if you $sql .= " WHERE rowid=".$this->id;
// want this action calls a trigger.
// // Call triggers dol_syslog(get_class($this)."::delete sql=".$sql);
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
// }
// }
if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account";
$sql .= " WHERE rowid=" . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (!$resql) {
$error ++; $error++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return - 1 * $error; return -1 * $error;
} else { } else {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
} else { } else {
return - 1; return -1;
} }
} }
@ -471,19 +455,19 @@ class AccountingAccount extends CommonObject
global $langs, $conf, $user; global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = ''; $result = '';
$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id;
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
$picto = 'billr'; $picto = 'billr';
$label=''; $label = '';
if (empty($this->labelshort) || $withcompletelabel == 1) if (empty($this->labelshort) || $withcompletelabel == 1)
{ {
@ -492,28 +476,28 @@ class AccountingAccount extends CommonObject
$labeltoshow = $this->labelshort; $labeltoshow = $this->labelshort;
} }
$label = '<u>' . $langs->trans("ShowAccountingAccount") . '</u>'; $label = '<u>'.$langs->trans("ShowAccountingAccount").'</u>';
if (! empty($this->account_number)) if (!empty($this->account_number))
$label .= '<br><b>'.$langs->trans('AccountAccounting') . ':</b> ' . length_accountg($this->account_number); $label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
if (! empty($labeltoshow)) if (!empty($labeltoshow))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $labeltoshow; $label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
if ($moretitle) $label.=' - '.$moretitle; if ($moretitle) $label .= ' - '.$moretitle;
$linkclose=''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip))
{ {
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label=$langs->trans("ShowAccoutingAccount"); $label = $langs->trans("ShowAccoutingAccount");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"'; $linkclose .= ' class="classfortooltip"';
} }
$linkstart='<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend='</a>'; $linkend = '</a>';
if ($nourl) if ($nourl)
{ {
@ -523,11 +507,11 @@ class AccountingAccount extends CommonObject
} }
$label_link = length_accountg($this->account_number); $label_link = length_accountg($this->account_number);
if ($withlabel) $label_link .= ' - ' . $labeltoshow; if ($withlabel) $label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$labeltoshow.($nourl ? '</span>' : '');
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend);
if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend;
return $result; return $result;
} }
@ -540,10 +524,10 @@ class AccountingAccount extends CommonObject
public function info($id) public function info($id)
{ {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a';
$sql .= ' WHERE a.rowid = ' . $id; $sql .= ' WHERE a.rowid = '.$id;
dol_syslog(get_class($this) . '::info sql=' . $sql); dol_syslog(get_class($this).'::info sql='.$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -594,11 +578,11 @@ class AccountingAccount extends CommonObject
if ($result > 0) { if ($result > 0) {
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
$sql .= "SET " . $fieldtouse . " = '0'"; $sql .= "SET ".$fieldtouse." = '0'";
$sql .= " WHERE rowid = " . $this->db->escape($id); $sql .= " WHERE rowid = ".$this->db->escape($id);
dol_syslog(get_class($this) . "::account_desactivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::account_desactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -607,10 +591,10 @@ class AccountingAccount extends CommonObject
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return - 1; return -1;
} }
} else { } else {
return - 1; return -1;
} }
} }
@ -636,11 +620,11 @@ class AccountingAccount extends CommonObject
$fieldtouse = 'reconcilable'; $fieldtouse = 'reconcilable';
} }
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
$sql .= "SET " . $fieldtouse . " = '1'"; $sql .= "SET ".$fieldtouse." = '1'";
$sql .= " WHERE rowid = " . $this->db->escape($id); $sql .= " WHERE rowid = ".$this->db->escape($id);
dol_syslog(get_class($this) . "::account_activate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$this->db->commit(); $this->db->commit();
@ -648,7 +632,7 @@ class AccountingAccount extends CommonObject
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return - 1; return -1;
} }
} }

View File

@ -266,7 +266,7 @@ class AccountingJournal extends CommonObject
} }
$label_link = $this->code; $label_link = $this->code;
if ($withlabel) $label_link .= ' - '.$langs->transnoentities($this->label); if ($withlabel) $label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$langs->transnoentities($this->label).($nourl ? '</span>' : '');
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);

View File

@ -361,20 +361,20 @@ class BookKeeping extends CommonObject
$sql .= ", '".$this->db->escape($this->doc_ref)."'"; $sql .= ", '".$this->db->escape($this->doc_ref)."'";
$sql .= ", ".$this->fk_doc; $sql .= ", ".$this->fk_doc;
$sql .= ", ".$this->fk_docdet; $sql .= ", ".$this->fk_docdet;
$sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL"); $sql .= ", ".(!empty($this->thirdparty_code) ? ("'".$this->db->escape($this->thirdparty_code)."'") : "NULL");
$sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL"); $sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL");
$sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL"); $sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->numero_compte)."'"; $sql .= ", '".$this->db->escape($this->numero_compte)."'";
$sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL"); $sql .= ", ".(!empty($this->label_operation) ? ("'".$this->db->escape($this->label_operation)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->label_operation)."'"; $sql .= ", '".$this->db->escape($this->label_operation)."'";
$sql .= ", ".$this->debit; $sql .= ", ".$this->debit;
$sql .= ", ".$this->credit; $sql .= ", ".$this->credit;
$sql .= ", ".$this->montant; $sql .= ", ".$this->montant;
$sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL"); $sql .= ", ".(!empty($this->sens) ? ("'".$this->db->escape($this->sens)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->fk_user_author)."'"; $sql .= ", '".$this->db->escape($this->fk_user_author)."'";
$sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'";
$sql .= ", '".$this->db->escape($this->code_journal)."'"; $sql .= ", '".$this->db->escape($this->code_journal)."'";
$sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL"); $sql .= ", ".(!empty($this->journal_label) ? ("'".$this->db->escape($this->journal_label)."'") : "NULL");
$sql .= ", ".$this->db->escape($this->piece_num); $sql .= ", ".$this->db->escape($this->piece_num);
$sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ")"; $sql .= ")";
@ -1397,7 +1397,7 @@ class BookKeeping extends CommonObject
$sql = "DELETE"; $sql = "DELETE";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
$sql.= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear); $sql .= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear);
if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'";
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity IN (".getEntity('accountancy').")";

View File

@ -24,9 +24,9 @@
* \brief File of class for lettering * \brief File of class for lettering
*/ */
include_once DOL_DOCUMENT_ROOT . "/accountancy/class/bookkeeping.class.php"; include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php";
include_once DOL_DOCUMENT_ROOT . "/societe/class/societe.class.php"; include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
include_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php"; include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
/** /**
* Class Lettering * Class Lettering
@ -64,15 +64,15 @@ class Lettering extends BookKeeping
$sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, "; $sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, ";
$sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant "; $sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant ";
$sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type "; $sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE ( "; $sql .= " WHERE ( ";
if ($object->code_compta != "") if ($object->code_compta != "")
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '".$object->code_compta."' ";
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") if ($object->code_compta != "" && $object->code_compta_fournisseur != "")
$sql .= " OR "; $sql .= " OR ";
if ($object->code_compta_fournisseur != "") if ($object->code_compta_fournisseur != "")
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) "; $sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
$sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) "; $sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
@ -85,127 +85,127 @@ class Lettering extends BookKeeping
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql) ) { while ($obj = $this->db->fetch_object($resql)) {
$ids = array(); $ids = array();
$ids_fact = array(); $ids_fact = array();
if ($obj->type == 'payment_supplier') if ($obj->type == 'payment_supplier')
{ {
$sql = 'SELECT DISTINCT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank, facf.rowid as fact_id'; $sql = 'SELECT DISTINCT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank, facf.rowid as fact_id';
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='" . $obj->code_journal . "')"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='".$obj->code_journal."')";
$sql .= " WHERE payfacf.fk_paiementfourn = '" . $obj->url_id . "' "; $sql .= " WHERE payfacf.fk_paiementfourn = '".$obj->url_id."' ";
$sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '".$object->code_compta."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
} }
$sql .= " ) "; $sql .= " ) ";
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if ($resql2) { if ($resql2) {
while ( $obj2 = $this->db->fetch_object($resql2) ) { while ($obj2 = $this->db->fetch_object($resql2)) {
$ids[$obj2->rowid] = $obj2->rowid; $ids[$obj2->rowid] = $obj2->rowid;
$ids_fact[] = $obj2->fact_id; $ids_fact[] = $obj2->fact_id;
} }
} else { } else {
$this->errors[] = $this->db->lasterror; $this->errors[] = $this->db->lasterror;
return - 1; return -1;
} }
if (count($ids_fact)) { if (count($ids_fact)) {
$sql = 'SELECT bk.rowid, facf.ref, facf.ref_supplier '; $sql = 'SELECT bk.rowid, facf.ref, facf.ref_supplier ';
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (" . implode(',', $ids_fact) . "))"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (".implode(',', $ids_fact)."))";
$sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3 AND entity=".$conf->entity.") "; $sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") ";
$sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '".$object->code_compta."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
} }
$sql .= ") "; $sql .= ") ";
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if ($resql2) { if ($resql2) {
while ( $obj2 = $this->db->fetch_object($resql2) ) { while ($obj2 = $this->db->fetch_object($resql2)) {
$ids[$obj2->rowid] = $obj2->rowid; $ids[$obj2->rowid] = $obj2->rowid;
} }
} else { } else {
$this->errors[] = $this->db->lasterror; $this->errors[] = $this->db->lasterror;
return - 1; return -1;
} }
} }
} elseif ($obj->type == 'payment') { } elseif ($obj->type == 'payment') {
$sql = 'SELECT DISTINCT bk.rowid, fac.ref, fac.ref, pay.fk_bank, fac.rowid as fact_id'; $sql = 'SELECT DISTINCT bk.rowid, fac.ref, fac.ref, pay.fk_bank, fac.rowid as fact_id';
$sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sql .= " FROM ".MAIN_DB_PREFIX."facture fac ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement as pay ON payfac.fk_paiement=pay.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='" . $obj->code_journal . "')"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='".$obj->code_journal."')";
$sql .= " WHERE payfac.fk_paiement = '" . $obj->url_id . "' "; $sql .= " WHERE payfac.fk_paiement = '".$obj->url_id."' ";
$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '".$object->code_compta."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
} }
$sql .= " ) "; $sql .= " )";
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if ($resql2) { if ($resql2) {
while ( $obj2 = $this->db->fetch_object($resql2) ) { while ($obj2 = $this->db->fetch_object($resql2)) {
$ids[$obj2->rowid] = $obj2->rowid; $ids[$obj2->rowid] = $obj2->rowid;
$ids_fact[] = $obj2->fact_id; $ids_fact[] = $obj2->fact_id;
} }
} else { } else {
$this->errors[] = $this->db->lasterror; $this->errors[] = $this->db->lasterror;
return - 1; return -1;
} }
if (count($ids_fact)) { if (count($ids_fact)) {
$sql = 'SELECT bk.rowid, fac.ref, fac.ref_supplier '; $sql = 'SELECT bk.rowid, fac.ref, fac.ref_supplier ';
$sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sql .= " FROM ".MAIN_DB_PREFIX."facture fac ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (" . implode(',', $ids_fact) . "))"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (".implode(',', $ids_fact)."))";
$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; $sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '".$object->code_compta."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
} }
$sql .= " ) "; $sql .= " ) ";
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if ($resql2) { if ($resql2) {
while ( $obj2 = $this->db->fetch_object($resql2) ) { while ($obj2 = $this->db->fetch_object($resql2)) {
$ids[$obj2->rowid] = $obj2->rowid; $ids[$obj2->rowid] = $obj2->rowid;
} }
} else { } else {
$this->errors[] = $this->db->lasterror; $this->errors[] = $this->db->lasterror;
return - 1; return -1;
} }
} }
} }
@ -217,10 +217,10 @@ class Lettering extends BookKeeping
} }
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::" . __METHOD__ . $errmsg, LOG_ERR); dol_syslog(__METHOD__.' '.$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
return - 1 * $error; return -1 * $error;
} else { } else {
return 1; return 1;
} }
@ -237,33 +237,31 @@ class Lettering extends BookKeeping
$error = 0; $error = 0;
$lettre = 'AAA'; $lettre = 'AAA';
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql = "SELECT DISTINCT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1; "; $sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1; ";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code); $lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code);
if (! empty($obj->lettering_code)) if (!empty($obj->lettering_code))
$lettre++; $lettre++;
} else { } else {
$this->errors[] = 'Error' . $this->db->lasterror(); $this->errors[] = 'Error'.$this->db->lasterror();
$error++; $error++;
} }
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql .= " rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL "; $sql .= " rowid IN (".implode(',', $ids).") AND date_validated IS NULL ";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if (! (round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) {
$this->errors[] = 'Total not exacts ' . round(abs($obj->deb), 2) . ' vs ' . round(abs($obj->cred), 2); $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2);
$error++; $error++;
} }
} else { } else {
$this->errors[] = 'Erreur sql' . $this->db->lasterror(); $this->errors[] = 'Erreur sql'.$this->db->lasterror();
$error++; $error++;
} }
@ -271,43 +269,30 @@ class Lettering extends BookKeeping
$now = dol_now(); $now = dol_now();
if (! $error) if (!$error)
{ {
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql .= " lettering_code='" . $lettre . "'"; $sql .= " lettering_code='".$lettre."'";
$sql .= " , date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false $sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false
$sql .= " WHERE rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL "; $sql .= " WHERE rowid IN (".implode(',', $ids).") AND date_validated IS NULL ";
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
} }
if (! $error) {
if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
}
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return - 1 * $error; return -1 * $error;
} else { } else {
$this->db->commit(); $this->db->commit();
return 1; return 1;

View File

@ -167,7 +167,7 @@ if ($action == 'validatehistory') {
$suggestedaccountingaccountfor = 'eecwithvat'; $suggestedaccountingaccountfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = 0; // There is a doubt, no automatic binding $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding
$suggestedaccountingaccountfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra; $objp->code_sell_p = $objp->code_sell_intra;

View File

@ -499,7 +499,7 @@ if ($result) {
$suggestedaccountingaccountfor = 'eecwithvat'; $suggestedaccountingaccountfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
$suggestedaccountingaccountfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra; $objp->code_sell_p = $objp->code_sell_intra;
@ -512,7 +512,7 @@ if ($result) {
} }
} }
if (! empty($objp->code_sell_p)) { if (!empty($objp->code_sell_p)) {
// Value was defined previously // Value was defined previously
} else { } else {
$code_sell_p_notset = 'color:orange'; $code_sell_p_notset = 'color:orange';
@ -595,7 +595,7 @@ if ($result) {
/*var_dump($suggestedid); /*var_dump($suggestedid);
var_dump($objp->code_sell_p); var_dump($objp->code_sell_p);
var_dump($objp->code_sell_l);*/ var_dump($objp->code_sell_l);*/
if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
{ {
if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l])) if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l]))
{ {
@ -632,7 +632,7 @@ if ($result) {
print $db->error(); print $db->error();
} }
if ($db->type == 'mysqli') { if ($db->type == 'mysqli') {
$db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
} }
// Add code to auto check the box when we select an account // Add code to auto check the box when we select an account

View File

@ -90,10 +90,10 @@ if ($conf->accounting->enabled)
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial); print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
print "<br>\n"; print "<br>\n";
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
print "<br>\n";print "<br>\n"; print "<br>\n"; print "<br>\n";
print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
print '<hr>'; print '<hr>';

View File

@ -31,37 +31,37 @@
* \brief Page with bank journal * \brief Page with bank journal
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.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/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.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 . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.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 . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.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 . '/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("companies","other","compta","banks","bills","donations","loan","accountancy","trips","salaries","hrm","members")); $langs->loadLangs(array("companies", "other", "compta", "banks", "bills", "donations", "loan", "accountancy", "trips", "salaries", "hrm", "members"));
// Multi journal // Multi journal
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
@ -95,13 +95,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
if ($pastmonth == 0) { if ($pastmonth == 0) {
$pastmonth = 12; $pastmonth = 12;
$pastmonthyear --; $pastmonthyear--;
} }
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{ {
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@ -112,26 +112,26 @@ $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_jour
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,"; $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,";
$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; $sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " JOIN ".MAIN_DB_PREFIX."bank_account as ba on b.fk_account=ba.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid";
$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; $sql .= " WHERE ba.fk_accountancy_journal=".$id_journal;
$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy $sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'";
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already')
{ {
$sql .= " AND (b.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; $sql .= " AND (b.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
} }
if ($in_bookkeeping == 'notyet') if ($in_bookkeeping == 'notyet')
{ {
$sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
} }
$sql .= " ORDER BY b.datev"; $sql .= " ORDER BY b.datev";
//print $sql; //print $sql;
@ -149,7 +149,7 @@ $paymentsalstatic = new PaymentSalary($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentexpensereportstatic = new PaymentExpenseReport($db);
$paymentvariousstatic = new PaymentVarious($db); $paymentvariousstatic = new PaymentVarious($db);
$paymentloanstatic = new PaymentLoan($db); $paymentloanstatic = new PaymentLoan($db);
$accountLinestatic=new AccountLine($db); $accountLinestatic = new AccountLine($db);
$paymentsubscriptionstatic = new Subscription($db); $paymentsubscriptionstatic = new Subscription($db);
$tmppayment = new Paiement($db); $tmppayment = new Paiement($db);
@ -171,20 +171,20 @@ if ($result) {
//print $sql; //print $sql;
// Variables // Variables
$account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
$account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word $account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word
$account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word $account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_subscription = (! empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word $account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word
$tabcompany = array(); $tabcompany = array();
$tabuser = array(); $tabuser = array();
$tabpay = array (); $tabpay = array();
$tabbq = array (); $tabbq = array();
$tabtp = array (); $tabtp = array();
$tabtype = array (); $tabtype = array();
$tabmoreinfo = array(); $tabmoreinfo = array();
// Loop on each line into llx_bank table. For each line, we should get: // Loop on each line into llx_bank table. For each line, we should get:
@ -199,8 +199,8 @@ if ($result) {
$lineisapurchase = -1; $lineisapurchase = -1;
$lineisasale = -1; $lineisasale = -1;
// Old method to detect if it's a sale or purchase // Old method to detect if it's a sale or purchase
if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1; if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase = 1;
if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1; if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale = 1;
// Try a more reliable method to detect if record is a supplier payment or a customer payment // Try a more reliable method to detect if record is a supplier payment or a customer payment
if ($lineisapurchase < 0) if ($lineisapurchase < 0)
{ {
@ -221,9 +221,9 @@ if ($result) {
if ($lineisapurchase > 0) if ($lineisapurchase > 0)
$compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier); $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
if ($lineisasale > 0) if ($lineisasale > 0)
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $account_customer);
$tabcompany[$obj->rowid] = array ( $tabcompany[$obj->rowid] = array(
'id' => $obj->socid, 'id' => $obj->socid,
'name' => $obj->name, 'name' => $obj->name,
'code_compta' => $compta_soc, 'code_compta' => $compta_soc,
@ -231,9 +231,9 @@ if ($result) {
); );
// Set accountancy code for user // Set accountancy code for user
$compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee);
$tabuser[$obj->rowid] = array ( $tabuser[$obj->rowid] = array(
'id' => $obj->userid, 'id' => $obj->userid,
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'lastname' => $obj->lastname, 'lastname' => $obj->lastname,
@ -244,8 +244,8 @@ if ($result) {
// Variable bookkeeping ($obj->rowid is Bank Id) // Variable bookkeeping ($obj->rowid is Bank Id)
$tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ...
$tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
$tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref;
$tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account;
@ -254,14 +254,14 @@ if ($result) {
} else { } else {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
} }
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
//var_dump($i); //var_dump($i);
//var_dump($tabpay); //var_dump($tabpay);
//var_dump($tabcompany); //var_dump($tabcompany);
// By default // By default
$tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url.
$tabtype[$obj->rowid] = 'unknown'; $tabtype[$obj->rowid] = 'unknown';
$tabmoreinfo[$obj->rowid] = array(); $tabmoreinfo[$obj->rowid] = array();
@ -287,18 +287,18 @@ if ($result) {
} }
if ($links[$key]['type'] == 'withdraw') { if ($links[$key]['type'] == 'withdraw') {
$tabmoreinfo[$obj->rowid]['withdraw']=1; $tabmoreinfo[$obj->rowid]['withdraw'] = 1;
} }
if ($links[$key]['type'] == 'payment') { if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id']; $paymentstatic->id = $links[$key]['url_id'];
$paymentstatic->ref = $links[$key]['url_id']; $paymentstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this
$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
} elseif ($links[$key]['type'] == 'payment_supplier') { } elseif ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id']; $paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
} elseif ($links[$key]['type'] == 'company') { } elseif ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id']; $societestatic->id = $links[$key]['url_id'];
@ -313,13 +313,13 @@ if ($result) {
$userstatic->firstname = $tabuser[$obj->rowid]['firstname']; $userstatic->firstname = $tabuser[$obj->rowid]['firstname'];
$userstatic->lastname = $tabuser[$obj->rowid]['lastname']; $userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30);
else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount; if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount;
} elseif ($links[$key]['type'] == 'sc') { } elseif ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id']; $chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution') if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution'; $reg[1] = 'SocialContribution';
@ -332,13 +332,13 @@ if ($result) {
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
$sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; $sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
@ -348,14 +348,14 @@ if ($result) {
$paymentdonstatic->id = $links[$key]['url_id']; $paymentdonstatic->id = $links[$key]['url_id'];
$paymentdonstatic->ref = $links[$key]['url_id']; $paymentdonstatic->ref = $links[$key]['url_id'];
$paymentdonstatic->fk_donation = $links[$key]['url_id']; $paymentdonstatic->fk_donation = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
$tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
} elseif ($links[$key]['type'] == 'member') { } elseif ($links[$key]['type'] == 'member') {
$paymentsubscriptionstatic->id = $links[$key]['url_id']; $paymentsubscriptionstatic->id = $links[$key]['url_id'];
$paymentsubscriptionstatic->ref = $links[$key]['url_id']; $paymentsubscriptionstatic->ref = $links[$key]['url_id'];
$paymentsubscriptionstatic->label = $links[$key]['label']; $paymentsubscriptionstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsubscriptionstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
$paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
$tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount; $tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount;
@ -363,14 +363,14 @@ if ($result) {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label']; $paymentvatstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
$tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
} elseif ($links[$key]['type'] == 'payment_salary') { } elseif ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label']; $paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
} elseif ($links[$key]['type'] == 'payment_expensereport') { } elseif ($links[$key]['type'] == 'payment_expensereport') {
$paymentexpensereportstatic->id = $links[$key]['url_id']; $paymentexpensereportstatic->id = $links[$key]['url_id'];
@ -380,25 +380,25 @@ if ($result) {
$paymentvariousstatic->id = $links[$key]['url_id']; $paymentvariousstatic->id = $links[$key]['url_id'];
$paymentvariousstatic->ref = $links[$key]['url_id']; $paymentvariousstatic->ref = $links[$key]['url_id'];
$paymentvariousstatic->label = $links[$key]['label']; $paymentvariousstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
$paymentvariousstatic->fetch($paymentvariousstatic->id); $paymentvariousstatic->fetch($paymentvariousstatic->id);
$account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word
$account_subledger = (! empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word
$tabpay[$obj->rowid]["account_various"] = $account_various; $tabpay[$obj->rowid]["account_various"] = $account_various;
$tabtp[$obj->rowid][$account_subledger] += $obj->amount; $tabtp[$obj->rowid][$account_subledger] += $obj->amount;
} elseif ($links[$key]['type'] == 'payment_loan') { } elseif ($links[$key]['type'] == 'payment_loan') {
$paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->id = $links[$key]['url_id'];
$paymentloanstatic->ref = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id'];
$paymentloanstatic->fk_loan = $links[$key]['url_id']; $paymentloanstatic->fk_loan = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentloanstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id;
//$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount;
$sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
$sqlmid.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l';
$sqlmid.= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid; $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
@ -408,7 +408,7 @@ if ($result) {
} }
} elseif ($links[$key]['type'] == 'banktransfert') { } elseif ($links[$key]['type'] == 'banktransfert') {
$accountLinestatic->fetch($links[$key]['url_id']); $accountLinestatic->fetch($links[$key]['url_id']);
$tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- ' .$accountLinestatic ->getNomUrl(1); $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1);
$tabtp[$obj->rowid][$account_transfer] += $obj->amount; $tabtp[$obj->rowid][$account_transfer] += $obj->amount;
$bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']);
$tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2);
@ -420,14 +420,14 @@ if ($result) {
// If no links were found to know the amount on thirdparty, we try to guess it. // If no links were found to know the amount on thirdparty, we try to guess it.
// This may happens on bank entries without the links lines to 'company'. // This may happens on bank entries without the links lines to 'company'.
if (empty($tabtp[$obj->rowid]) && ! empty($tabmoreinfo[$obj->rowid]['withdraw'])) // If we dont find 'company' link because it is an old 'withdraw' record if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) // If we dont find 'company' link because it is an old 'withdraw' record
{ {
foreach ($links as $key => $val) { foreach ($links as $key => $val) {
if ($links[$key]['type'] == 'payment') { if ($links[$key]['type'] == 'payment') {
// Get thirdparty // Get thirdparty
$tmppayment->fetch($links[$key]['url_id']); $tmppayment->fetch($links[$key]['url_id']);
$arrayofamounts = $tmppayment->getAmountsArray(); $arrayofamounts = $tmppayment->getAmountsArray();
foreach($arrayofamounts as $invoiceid => $amount) foreach ($arrayofamounts as $invoiceid => $amount)
{ {
$tmpinvoice->fetch($invoiceid); $tmpinvoice->fetch($invoiceid);
$tmpinvoice->fetch_thirdparty(); $tmpinvoice->fetch_thirdparty();
@ -478,7 +478,7 @@ var_dump($tabtp);
var_dump($tabtype);*/ var_dump($tabtype);*/
// Write bookkeeping // Write bookkeeping
if (! $error && $action == 'writebookkeeping') { if (!$error && $action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0; $error = 0;
@ -501,7 +501,7 @@ if (! $error && $action == 'writebookkeeping') {
var_dump($tabbq);exit;*/ var_dump($tabbq);exit;*/
// Bank // Bank
if (! $errorforline && is_array($tabbq[$key])) if (!$errorforline && is_array($tabbq[$key]))
{ {
// Line into bank account // Line into bank account
foreach ($tabbq[$key] as $k => $mt) foreach ($tabbq[$key] as $k => $mt)
@ -509,9 +509,9 @@ if (! $error && $action == 'writebookkeeping') {
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
$reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']);
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -528,7 +528,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0 ? $mt : 0); $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
$bookkeeping->credit = ($mt < 0 ? - $mt : 0); $bookkeeping->credit = ($mt < 0 ? -$mt : 0);
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label; $bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
@ -562,7 +562,7 @@ if (! $error && $action == 'writebookkeeping') {
} }
// Third party // Third party
if (! $errorforline) if (!$errorforline)
{ {
if (is_array($tabtp[$key])) if (is_array($tabtp[$key]))
{ {
@ -571,14 +571,14 @@ if (! $error && $action == 'writebookkeeping') {
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":""); if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : "");
if ($tabtype[$key] == 'banktransfert') if ($tabtype[$key] == 'banktransfert')
{ {
$reflabel.= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
} }
else else
{ {
$reflabel.= dol_string_nohtmltag($val['soclib']); $reflabel .= dol_string_nohtmltag($val['soclib']);
} }
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
@ -590,7 +590,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->label_operation = $reflabel; $bookkeeping->label_operation = $reflabel;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? - $mt : 0); $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label; $bookkeeping->journal_label = $journal_label;
@ -598,15 +598,15 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->date_creation = $now; $bookkeeping->date_creation = $now;
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
$bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
$bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
$bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
$bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
$bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
@ -715,8 +715,8 @@ if (! $error && $action == 'writebookkeeping') {
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
$reflabel.= dol_string_nohtmltag('WaitingAccount'); $reflabel .= dol_string_nohtmltag('WaitingAccount');
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -726,7 +726,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? - $mt : 0); $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label; $bookkeeping->journal_label = $journal_label;
@ -767,7 +767,7 @@ if (! $error && $action == 'writebookkeeping') {
setEventMessages('Try to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); setEventMessages('Try to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors');
} }
if (! $errorforline) if (!$errorforline)
{ {
$db->commit(); $db->commit();
} }
@ -776,11 +776,11 @@ if (! $error && $action == 'writebookkeeping') {
//print 'KO for line '.$key.' '.$error.'<br>'; //print 'KO for line '.$key.' '.$error.'<br>';
$db->rollback(); $db->rollback();
$MAXNBERRORS=5; $MAXNBERRORS = 5;
if ($error >= $MAXNBERRORS) if ($error >= $MAXNBERRORS)
{ {
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors');
break; // Break in the foreach break; // Break in the foreach
} }
} }
} }
@ -802,15 +802,15 @@ if (! $error && $action == 'writebookkeeping') {
// Must reload data, so we make a redirect // Must reload data, so we make a redirect
if (count($tabpay) != $error) if (count($tabpay) != $error)
{ {
$param='id_journal='.$id_journal; $param = 'id_journal='.$id_journal;
$param.='&date_startday='.$date_startday; $param .= '&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth; $param .= '&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear; $param .= '&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday; $param .= '&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth; $param .= '&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear; $param .= '&date_endyear='.$date_endyear;
$param.='&in_bookkeeping='.$in_bookkeeping; $param .= '&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
exit; exit;
} }
} }
@ -823,20 +823,20 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$filename = 'journal'; $filename = 'journal';
$type_export = 'journal'; $type_export = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
// CSV header line // CSV header line
print '"' . $langs->transnoentitiesnoconv("BankId").'"' . $sep; print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("PaymentMode") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("LedgerAccount") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("SubledgerAccount") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("Label"). '"' . $sep; print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("Debit") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("Debit").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("Credit") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("Credit").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("Journal") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep;
print '"' . $langs->transnoentitiesnoconv("Note") . '"' . $sep; print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep;
print "\n"; print "\n";
foreach ($tabpay as $key => $val) foreach ($tabpay as $key => $val)
@ -850,21 +850,21 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
$reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']);
print '"' . $key . '"' . $sep; print '"'.$key.'"'.$sep;
print '"' . $date . '"' . $sep; print '"'.$date.'"'.$sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"'.$val["type_payment"].'"'.$sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print " " . $sep; print " ".$sep;
print '"' . $reflabel . '"' . $sep; print '"'.$reflabel.'"'.$sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"' . $journal . '"' . $sep; print '"'.$journal.'"'.$sep;
print '"' . dol_string_nohtmltag($ref) . '"' . $sep; print '"'.dol_string_nohtmltag($ref).'"'.$sep;
print "\n"; print "\n";
} }
} }
@ -875,37 +875,37 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":""); if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : "");
if ($tabtype[$key] == 'banktransfert') if ($tabtype[$key] == 'banktransfert')
{ {
$reflabel.= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
} }
else else
{ {
$reflabel.= dol_string_nohtmltag($val['soclib']); $reflabel .= dol_string_nohtmltag($val['soclib']);
} }
print '"' . $key . '"' . $sep; print '"'.$key.'"'.$sep;
print '"' . $date . '"' . $sep; print '"'.$date.'"'.$sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"'.$val["type_payment"].'"'.$sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
if ($tabtype[$key] == 'payment_supplier') { if ($tabtype[$key] == 'payment_supplier') {
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
} elseif($tabtype[$key] == 'payment') { } elseif ($tabtype[$key] == 'payment') {
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep;
} elseif($tabtype[$key] == 'payment_expensereport') { } elseif ($tabtype[$key] == 'payment_expensereport') {
print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
} elseif($tabtype[$key] == 'payment_salary') { } elseif ($tabtype[$key] == 'payment_salary') {
print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
} else { } else {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
} }
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"' . $reflabel . '"' . $sep; print '"'.$reflabel.'"'.$sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"' . $journal . '"' . $sep; print '"'.$journal.'"'.$sep;
print '"' . dol_string_nohtmltag($ref) . '"' . $sep; print '"'.dol_string_nohtmltag($ref).'"'.$sep;
print "\n"; print "\n";
} }
} }
@ -914,20 +914,20 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
$reflabel.= dol_string_nohtmltag('WaitingAccount'); $reflabel .= dol_string_nohtmltag('WaitingAccount');
print '"' . $key . '"' . $sep; print '"'.$key.'"'.$sep;
print '"' . $date . '"' . $sep; print '"'.$date.'"'.$sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"'.$val["type_payment"].'"'.$sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
print "" . $sep; print "".$sep;
print '"' . $reflabel . '"' . $sep; print '"'.$reflabel.'"'.$sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"' . $journal . '"' . $sep; print '"'.$journal.'"'.$sep;
print '"' . dol_string_nohtmltag($ref) . '"' . $sep; print '"'.dol_string_nohtmltag($ref).'"'.$sep;
print "\n"; print "\n";
} }
} }
@ -954,16 +954,16 @@ if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
$nom = $langs->trans("FinanceJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); $nom = $langs->trans("FinanceJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$builddate=dol_now(); $builddate = dol_now();
//$description = $langs->trans("DescFinanceJournal") . '<br>'; //$description = $langs->trans("DescFinanceJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal='.$id_journal;
journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
@ -994,15 +994,15 @@ if (empty($action) || $action == 'view') {
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom">';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|| ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} }
else { else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>'; else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
} }
print '</div>'; print '</div>';
@ -1033,14 +1033,14 @@ if (empty($action) || $action == 'view') {
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>".$langs->trans("Date")."</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>"; print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>"; print "<td>".$langs->trans("AccountAccounting")."</td>";
print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; print "<td>".$langs->trans("SubledgerAccount")."</td>";
print "<td>" . $langs->trans("LabelOperation") . "</td>"; print "<td>".$langs->trans("LabelOperation")."</td>";
print '<td class="center">' . $langs->trans("PaymentMode") . "</td>"; print '<td class="center">'.$langs->trans("PaymentMode")."</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>";
print "</tr>\n"; print "</tr>\n";
$r = ''; $r = '';
@ -1057,15 +1057,15 @@ if (empty($action) || $action == 'view') {
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - "; if (!empty($val['lib'])) $reflabel .= $val['lib']." - ";
$reflabel.= $langs->trans("Bank").' '.$val['bank_account_ref']; $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref'];
if (! empty($val['soclib'])) $reflabel .= " - " . $val['soclib']; if (!empty($val['soclib'])) $reflabel .= " - ".$val['soclib'];
//var_dump($tabpay[$key]); //var_dump($tabpay[$key]);
print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>" . $date . "</td>"; print "<td>".$date."</td>";
print "<td>" . $ref . "</td>"; print "<td>".$ref."</td>";
// Ledger account // Ledger account
print "<td>"; print "<td>";
$accounttoshow = length_accountg($k); $accounttoshow = length_accountg($k);
@ -1087,9 +1087,9 @@ if (empty($action) || $action == 'view') {
print "<td>"; print "<td>";
print $reflabel; print $reflabel;
print "</td>"; print "</td>";
print '<td class="center">' . $val["type_payment"] . "</td>"; print '<td class="center">'.$val["type_payment"]."</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>"; print "</tr>";
} }
} }
@ -1100,20 +1100,20 @@ if (empty($action) || $action == 'view') {
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= $val['lib'] . ($val['soclib']?" - ":""); if (!empty($val['lib'])) $reflabel .= $val['lib'].($val['soclib'] ? " - " : "");
if ($tabtype[$key] == 'banktransfert') if ($tabtype[$key] == 'banktransfert')
{ {
$reflabel.= $langs->trans('TransitionalAccount').' '.$account_transfer; $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer;
} }
else else
{ {
$reflabel.= $val['soclib']; $reflabel .= $val['soclib'];
} }
print '<!-- Thirdparty bank.rowid='.$key.' -->'; print '<!-- Thirdparty bank.rowid='.$key.' -->';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>" . $date . "</td>"; print "<td>".$date."</td>";
print "<td>" . $ref . "</td>"; print "<td>".$ref."</td>";
// Ledger account // Ledger account
print "<td>"; print "<td>";
$account_ledger = $k; $account_ledger = $k;
@ -1137,19 +1137,19 @@ if (empty($action) || $action == 'view') {
} }
else else
{ {
print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account
} }
} }
else else
{ {
// We will refuse writing // We will refuse writing
$errorstring='UnknownAccountForThirdpartyBlocking'; $errorstring = 'UnknownAccountForThirdpartyBlocking';
if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined'; if ($tabtype[$key] == 'payment') $errorstring = 'MainAccountForCustomersNotDefined';
if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined'; if ($tabtype[$key] == 'payment_supplier') $errorstring = 'MainAccountForSuppliersNotDefined';
if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined'; if ($tabtype[$key] == 'payment_expensereport') $errorstring = 'MainAccountForUsersNotDefined';
if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined'; if ($tabtype[$key] == 'payment_salary') $errorstring = 'MainAccountForUsersNotDefined';
if ($tabtype[$key] == 'payment_vat') $errorstring='MainAccountForVatPaymentNotDefined'; if ($tabtype[$key] == 'payment_vat') $errorstring = 'MainAccountForVatPaymentNotDefined';
if ($tabtype[$key] == 'member') $errorstring='MainAccountForSubscriptionPaymentNotDefined'; if ($tabtype[$key] == 'member') $errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
print '<span class="error">'.$langs->trans($errorstring).'</span>'; print '<span class="error">'.$langs->trans($errorstring).'</span>';
} }
} }
@ -1169,7 +1169,7 @@ if (empty($action) || $action == 'view') {
var_dump($tabtype[$key]); var_dump($tabtype[$key]);
var_dump($tabbq[$key]);*/ var_dump($tabbq[$key]);*/
//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
if (! empty($tabcompany[$key]['code_compta'])) if (!empty($tabcompany[$key]['code_compta']))
{ {
if (in_array($tabtype[$key], array('payment_various'))) { if (in_array($tabtype[$key], array('payment_various'))) {
// For such case, if subledger is not defined, we won't use subledger accounts. // For such case, if subledger is not defined, we won't use subledger accounts.
@ -1187,10 +1187,10 @@ if (empty($action) || $action == 'view') {
} }
} }
print "</td>"; print "</td>";
print "<td>" . $reflabel . "</td>"; print "<td>".$reflabel."</td>";
print '<td class="center">' . $val["type_payment"] . "</td>"; print '<td class="center">'.$val["type_payment"]."</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>"; print "</tr>";
} }
} }
@ -1199,13 +1199,13 @@ if (empty($action) || $action == 'view') {
if ($mt) if ($mt)
{ {
$reflabel = ''; $reflabel = '';
if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - "; if (!empty($val['lib'])) $reflabel .= $val['lib']." - ";
$reflabel.= 'WaitingAccount'; $reflabel .= 'WaitingAccount';
print '<!-- Wait bank.rowid='.$key.' -->'; print '<!-- Wait bank.rowid='.$key.' -->';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>" . $date . "</td>"; print "<td>".$date."</td>";
print "<td>" . $ref . "</td>"; print "<td>".$ref."</td>";
// Ledger account // Ledger account
print "<td>"; print "<td>";
/*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
@ -1223,10 +1223,10 @@ if (empty($action) || $action == 'view') {
else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
*/ */
print "</td>"; print "</td>";
print "<td>" . $reflabel . "</td>"; print "<td>".$reflabel."</td>";
print '<td class="center">' . $val["type_payment"] . "</td>"; print '<td class="center">'.$val["type_payment"]."</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>"; print "</tr>";
} }
} }
@ -1287,63 +1287,63 @@ function getSourceDocRef($val, $typerecord)
{ {
$sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref'; $sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f";
$sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=".$val["paymentid"];
$ref = $langs->transnoentitiesnoconv("Invoice"); $ref = $langs->transnoentitiesnoconv("Invoice");
} }
elseif ($typerecord == 'payment_supplier') elseif ($typerecord == 'payment_supplier')
{ {
$sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f";
$sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"];
$ref = $langs->transnoentitiesnoconv("SupplierInvoice"); $ref = $langs->transnoentitiesnoconv("SupplierInvoice");
} }
elseif ($typerecord == 'payment_expensereport') elseif ($typerecord == 'payment_expensereport')
{ {
$sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid = 'SELECT e.rowid as id, e.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e";
$sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; $sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid";
$ref = $langs->transnoentitiesnoconv("ExpenseReport"); $ref = $langs->transnoentitiesnoconv("ExpenseReport");
} }
elseif ($typerecord == 'payment_salary') elseif ($typerecord == 'payment_salary')
{ {
$sqlmid = 'SELECT s.rowid as ref'; $sqlmid = 'SELECT s.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; $sqlmid .= " WHERE s.rowid=".$val["paymentsalid"];
$ref = $langs->transnoentitiesnoconv("SalaryPayment"); $ref = $langs->transnoentitiesnoconv("SalaryPayment");
} }
elseif ($typerecord == 'sc') elseif ($typerecord == 'sc')
{ {
$sqlmid = 'SELECT sc.rowid as ref'; $sqlmid = 'SELECT sc.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc";
$sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"]; $sqlmid .= " WHERE sc.rowid=".$val["paymentscid"];
$ref = $langs->transnoentitiesnoconv("SocialContribution"); $ref = $langs->transnoentitiesnoconv("SocialContribution");
} }
elseif ($typerecord == 'payment_vat') elseif ($typerecord == 'payment_vat')
{ {
$sqlmid = 'SELECT v.rowid as ref'; $sqlmid = 'SELECT v.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; $sqlmid .= " WHERE v.rowid=".$val["paymentvatid"];
$ref = $langs->transnoentitiesnoconv("PaymentVat"); $ref = $langs->transnoentitiesnoconv("PaymentVat");
} }
elseif ($typerecord == 'payment_donation') elseif ($typerecord == 'payment_donation')
{ {
$sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid = 'SELECT payd.fk_donation as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd";
$sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; $sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"];
$ref = $langs->transnoentitiesnoconv("Donation"); $ref = $langs->transnoentitiesnoconv("Donation");
} }
elseif ($typerecord == 'payment_loan') elseif ($typerecord == 'payment_loan')
{ {
$sqlmid = 'SELECT l.rowid as ref'; $sqlmid = 'SELECT l.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l";
$sqlmid .= " WHERE l.rowid=" . $val["paymentloanid"]; $sqlmid .= " WHERE l.rowid=".$val["paymentloanid"];
$ref = $langs->transnoentitiesnoconv("LoanPayment"); $ref = $langs->transnoentitiesnoconv("LoanPayment");
} }
elseif ($typerecord == 'payment_various') elseif ($typerecord == 'payment_various')
{ {
$sqlmid = 'SELECT v.rowid as ref'; $sqlmid = 'SELECT v.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; $sqlmid .= " WHERE v.rowid=".$val["paymentvariousid"];
$ref = $langs->transnoentitiesnoconv("VariousPayment"); $ref = $langs->transnoentitiesnoconv("VariousPayment");
} }
// Add warning // Add warning
@ -1354,18 +1354,18 @@ function getSourceDocRef($val, $typerecord)
if ($sqlmid) if ($sqlmid)
{ {
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) if ($resultmid)
{ {
while ($objmid = $db->fetch_object($resultmid)) while ($objmid = $db->fetch_object($resultmid))
{ {
$ref.=' '.$objmid->ref; $ref .= ' '.$objmid->ref;
} }
} }
else dol_print_error($db); else dol_print_error($db);
} }
$ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300
return $ref; return $ref;
} }

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