Merge branch 'develop' into NEW_deposit_payment_terms

This commit is contained in:
Laurent Destailleur 2022-05-08 23:09:06 +02:00 committed by GitHub
commit b3b6337c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
949 changed files with 79648 additions and 91726 deletions

View File

@ -28,7 +28,7 @@ CKEditor 4.12.1 LGPL-2.1+ Yes
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
GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert
Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers
Mobiledetect 2.8.39 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)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.6 MIT License Yes Markdown parser
@ -48,10 +48,10 @@ TCPDF 6.3.2 LGPL-3+ Yes
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement
JS libraries:
Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea.
ChartJS 2.9.4 MIT License Yes JS library for graph
jQuery 3.5.1 MIT License Yes JS library
jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI
Ace 1.4.14 BSD Yes JS library to get code syntaxique coloration in a textarea.
ChartJS 3.7.1 MIT License Yes JS library for graph
jQuery 3.6.0 MIT License Yes JS library
jQuery UI 1.13.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. Warning: 4.0.6+ create troubles without patching css
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

View File

@ -9,7 +9,8 @@ English Dolibarr ChangeLog
For users:
---------------
NEW: ...
NEW: PHP 8.0 compatibility
Modules
@ -21,14 +22,23 @@ NEW: Experimental module Partnership Management
For developers:
---------------
NEW:
NEW: A lot of addition of hooks.
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* There is a new specific permission to be allowed to enter timesheets. If you use timesheet, don't forget to give the new permission (disable and
enable the module project if it is not visible).
* The default value for MAIN_SECURITY_CSRF_WITH_TOKEN has been set to 2. It means any POST and any GET request that contains the "action" or "massaction"
with a value of a sensitive action must also a valid token parameter (With previous value 1, only POST was concerned). Note: With value 3, any URL
with parameter "action" or "massaction" need the token, whatever is the value of the action.
* verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true.
* The deprecated mdethod thirdparty_doc_create() has been removed. You can use the generateDocument() instead.
* The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead.
* All triggers with a name XXX_UPDATE have been renamed with name XXX_MODIFY for code consistency purpose.
* Rename build_path_from_id_categ() into buildPathFromId() and set method to private.
* Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php
* Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code).
* Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions.
***** ChangeLog for 15.0.1 compared to 15.0.0 *****

View File

@ -111,7 +111,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Customers/Prospects + Contacts management
- Opportunities or Leads management
- Commercial proposals management
- Commercial proposals management (online signing)
- Customer Orders management
- Contracts/Subscription management
- Interventions management
@ -129,11 +129,11 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Supplier Invoices/credit notes and payment management
- INCOTERMS
Finance / Accounting
Finance/Accounting
- Invoices / Payments
- Invoices/Payments
- Bank accounts management
- Direct debit orders management (European SEPA)
- Direct debit and Credit transfer management (European SEPA)
- Accounting management
- Donations management
- Loan management
@ -142,14 +142,14 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
Collaboration
- Shared calendar/agenda (with ical and vcal export for third party tools integration)
- Shared calendar/agenda (with ical and vcal import/export for third party tools integration)
- Projects & Tasks management
- Ticket System
- Surveys
HR
- Employee's leave requests management
- Employee's leaves management
- Expense reports
- Recruitment management
- Timesheets
@ -157,16 +157,14 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
### Other application/modules
- Electronic Document Management (EDM)
- Bookmarks management
- Bookmarks
- Reporting
- Data export/import
- Barcodes
- Margin calculations
- LDAP connectivity
- ClickToDial integration
- Mass emailing
- RSS integration
- Skype integration
- Social platforms linking
- Payment platforms integration (PayPal, Stripe, Paybox...)
- Email-Collector
@ -175,13 +173,12 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
### Other general features
- Localization in most major languages
- Multi-Language Support
- Multi-Language Support (Localization in most major languages)
- Multi-Users and groups with finely grained rights
- Multi-Currency
- Multi-Company (by adding of an external module)
- Very user friendly and easy to use
- customizable Dashboard
- Customizable dashboards
- Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one)
- APIs (REST, SOAP)
- Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture)
@ -191,8 +188,9 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Canadian double taxes (federal/province) and other countries using cumulative VAT
- Tunisian tax stamp
- Argentina invoice numbering using A,B,C...
- ZATCA e-invoicing QR-Code
- Compatible with [European directives](https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE)
- Compatible with European GDPR rules
- Compatible with data privacy rules (europe GDPR, ...)
- ...
- Flexible PDF & ODT generation for invoices, proposals, orders...
- ...
@ -244,6 +242,7 @@ Follow Dolibarr project on:
- [Facebook](https://www.facebook.com/dolibarr)
- [Twitter](https://www.twitter.com/dolibarr)
- [LinkedIn](https://www.linkedin.com/company/association-dolibarr)
- [Reddit](https://www.reddit.com/r/Dolibarr_ERP_CRM/)
- [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
- [GitHub](https://github.com/Dolibarr/dolibarr)

View File

@ -17,7 +17,7 @@ Alternatively send an email to security@dolibarr.org (for everybody)
## Hunting vulnerabilities on Dolibarr
We believe that future of software is online SaaS. This means software are more and more critical and no technology is perfect. Working with skilled security researchers is crucial in identifying weaknesses in our technology.
We believe that the future of software is online SaaS. This means software are more and more critical and no technology is perfect. Working with skilled security researchers is crucial in identifying weaknesses in our technology.
If you believe you've found a security bug in our service, we are happy to work with you to resolve the issue promptly and ensure you are fairly rewarded for your discovery.
@ -35,13 +35,13 @@ You can install the web application yourself on your own platform/server so you
## Eligibility and Responsible Disclosure
We are happy to thank everyone who submits valid reports which help us improve the security of Dolibarr however, only those that meet the following eligibility requirements will be "validated reports" (if not, we may close the report without any answer):
We are happy to thank everyone who submits valid reports which help us improve the security of Dolibarr, however only those that meet the following eligibility requirements will be "validated reports" (if not, we may close the report without any answer):
You must be the first reporter of the vulnerability (duplicate reports are closed).
You must send a clear textual description of the report along with steps to reproduce the issue, include attachments such as screenshots or proof of concept code as necessary.
You must avoid tests that could cause degradation or interruption of our service (refrain from using automated tools, and limit yourself about requests per second), that's why we recommand to install softwate on your own platform.
You must avoid tests that could cause degradation or interruption of our service (refrain from using automated tools, and limit yourself about requests per second), that's why we recommand to install software on your own platform.
You must not leak, manipulate, or destroy any user data of third parties to find your vulnerability.
@ -56,7 +56,7 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us
* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools)
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.
* The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only.
* CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3.
* Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user.

View File

@ -8,12 +8,13 @@ This files describe steps made by Dolibarr packaging team to make a
beta version of Dolibarr, step by step.
- Check all files are commited.
- Update version/info in ChangeLog.
To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
- Update version/info in ChangeLog, for this you can:
To generate a changelog of a major new version x.y.0 (from a repo on branch develop), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a major new version x.y.0 (from a repo on branch x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
- To know number of lines changes: git diff --shortstat A B
- Update version number with x.y.z-w in htdocs/filefunc.inc.php
Recopy the content of the output file into the file ChangeLog.
- Note: To know number of lines changes: git diff --shortstat A B
- Update version number with x.y.z-w in file htdocs/filefunc.inc.php
- Commit all changes.
- Run makepack-dolibarr.pl to generate all packages.
@ -24,7 +25,6 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol
(/home/dolibarr/wwwroot/files/lastbuild).
- Post a news on dolibarr.org/dolibarr.fr + social networks
- Send mail on mailings-list
***** Actions to do a RELEASE *****
@ -32,12 +32,13 @@ This files describe steps made by Dolibarr packaging team to make a
complete release of Dolibarr, step by step.
- Check all files are commited.
- Update version/info in ChangeLog.
To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
- Update version/info in ChangeLog, for this you can:
To generate a changelog of a major new version x.y.0 (from a repo on branch develop), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a major new version x.y.0 (from a repo pn branch x.y), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
- To know number of lines changes: git diff --shortstat A B
- Update version number with x.y.z in htdocs/filefunc.inc.php
Recopy the content of the output file into the file ChangeLog.
- Note: To know the number of lines changes: git diff --shortstat A B
- Update version number with x.y.z in file htdocs/filefunc.inc.php
- Commit all changes.
- Run makepack-dolibarr.pl to generate all packages.
@ -52,4 +53,3 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol
on server to point to new files (used by some web sites).
- Post a news on dolibarr.org/dolibarr.fr + social networks
- Send mail on mailings-list

View File

@ -28,7 +28,7 @@
"ext-curl" : "*",
"ckeditor/ckeditor" : "4.12.1",
"mike42/escpos-php" : "2.2",
"mobiledetect/mobiledetectlib" : "2.8.34",
"mobiledetect/mobiledetectlib" : "2.8.39",
"phpoffice/phpexcel" : "1.8.2",
"restler/framework" : "3.0.0-RC6",
"tecnickcom/tcpdf" : "6.3.2",
@ -59,4 +59,4 @@
"ext-zip" : "ODT, Excel and file compression support",
"ext-xml" : "Excel support"
}
}
}

2349
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,13 +2,13 @@
Gestion escompte:
Sur une facture de 120 € TTC :
707xxx 100 € HT
44571x 20 € TVA
411xxx 120 € TTC
707xxx 100 € HT
44571x 20 € TVA
411xxx 120 € TTC
Le client règle rapidement et on lui accorde un escompte de 3% (120 € * 3% = 3.6 € TTC), on aura donc :
665000 3,00 € HT
44571x 0,60 € TVA
411xxx 3.60 € TVA
665000 3,00 € HT
44571x 0,60 € TVA
411xxx 3,60 € TTC
Et ça marche à linverse avec un fournisseur sauf que lon est en 775000 au lieu de 665000 pour escompte obtenus.

View File

@ -1,129 +0,0 @@
Barcode EAN 13
FR
==
Signification des chiffres.
- 2 chiffres pour le code pays ou code systeme
- 5 chiffres pour l'identificateur de societe
- 5 chiffres pour l'identificateur d'article
- 1 chiffre pour la somme de controle
Cette regle subit de nombreuses entorses pour ameliorer l'usage des chiffres disponibles.
Voici la liste des codes pays ou systeme :
EN
==
Meaning of the numbers.
- 2 digits for the country code or system code
- 5 digits for the company identifier
- 5 digits for item identifier
- 1 digit for checksum
This rule has been twisted many times to improve the use of the available numbers.
Here is the list of country codes or system:
List
====
00 <20> 13 UCC (Etats-Unis et Canada)
20 <20> 29 Codification interne en magasin
30 <20> 37 GENCOD-EAN France
380 BCCI (Bulgarie)
383 SANA (Slovenie)
385 CRO-EAN (Croatie)
387 EAN-BIH (Bosnie-Herzegovine)
400 <20> 440 CCG (Allemagne)
45 + 49 Distribution Code Center <20> DCC (Japon)
460 <20> 469 UNISCAN - EAN Russie (Federation de Russie)
471 CAN (Taiwan)
474 EAN Estonie
475 EAN Lettonie
476 EAN Azerba<62> djan
477 EAN Lituanie
478 EAN Ouzbekistan
479 EAN Sri Lanka
480 PANC (Philippines)
481 EAN Bielorussie
482 EAN Ukraine
484 EAN Moldavie
485 EAN Armenie
486 EAN Georgie
487 EAN Kazakhstan
489 HKANA (Hong Kong)
50 E Centre UK
520 HELLCAN-EAN HELLAS (Grece)
528 EAN Liban
529 EAN Chypre
531 EAN-MAC (FYR Mac<61>donie)
535 EAN Malte
539 EAN Irlande
54 ICODIF/EAN Belgique. Luxembourg
560 CODIPOR (Portugal)
569 EAN Islande
57 EAN Danemark
590 EAN Pologne
594 EAN Roumanie
599 H.A.P.M.H. (Hongrie)
600 - 601 EAN Afrique du Sud
609 EAN Ile Maurice
611 EAN Maroc
613 EAN Algerie
619 Tunicode (Tunisie)
621 EAN Syrie
622 EAN Egypte
625 EAN Jordanie
626 EAN Iran
628 EAN Arabie Saoudite
64 EAN Finlande
690 - 693 Article Numbering Centre of China - ANCC (Chine)
70 EAN Norge (Norvege)
729 Israeli Bar Code Association <20> EAN Israel
73 EAN Suede
740 EAN Guatemala
741 EAN El Salvador
742 ICCC (Honduras)
743 EAN Nicaragua
744 EAN Costa Rica Panama
746 746 EAN Republique Dominicaine
750 AMECE (Mexique)
759 EAN Venezuela
76 EAN (Schweiz, Suisse, Svizzera)
770 IAC (Colombie)
773 EAN Uruguay
775 APC - EAN Peru (Perou)
777 EAN Bolivie
779 CODIGO - EAN Argentine
780 EAN Chili
784 EAN Paraguay
786 ECOP (Equateur)
789 EAN Bresil
80 <20> 83 INDICOD (Italie)
84 AECOC (Espagne)
850 Camera de Comercio de la Republica de Cuba (Cuba)
858 EAN Slovaquie
859 EAN Republique Tcheque
860 EAN YU (Yougoslavie)
867 EAN DPR Korea (Coree du Nord)
869 Union of Chambers of Commerce of Turkey (Turquie)
87 EAN Nederland (Hollande)
880 EAN Korea (Coree du Sud)
885 EAN Thailande
888 SANC (Singapour)
890 EAN Inde
893 EAN Vietnam
899 EAN Indonesie
90 - 91 EAN Autriche
93 EAN Australie
94 EAN Nouvelle Zelande
955 Malaysian Article Numbering Council (MANC) - Malaisie
977 Publications sirielles (ISSN)
978 - 979 Livres (ISBN)
980 Refus de remboursement
981 - 982 Coupons (monnaie courante)
99 Coupons

View File

@ -1,3 +1,8 @@
QR-Code = Quick Response Code - is a two-dimensional / 2D- / Matrix-Barcode
ISO/IEC 18004
List of QR Code format we found on some invoices
------------------------------------------------

View File

@ -0,0 +1,129 @@
Barcode EAN 13
FR
==
Signification des chiffres.
- 2 chiffres pour le code pays ou code systeme
- 5 chiffres pour l'identificateur de societe
- 5 chiffres pour l'identificateur d'article
- 1 chiffre pour la somme de controle
Cette regle subit de nombreuses entorses pour ameliorer l'usage des chiffres disponibles.
Voici la liste des codes pays ou systeme :
EN
==
Meaning of the numbers:
- first 2-3 digits for the country code or system code
- 5 digits for the company identifier
- 5 digits for item identifier
- 1 digit for checksum
This rule has been twisted many times to improve the use of the available numbers.
Here is the list of country codes or system:
List
====
00 - 13 UCC (U.S.A / États-Unis & Canada)
20 - 29 Flag for internal numbering / Codification interne en magasin
30 - 37 GENCOD-EAN France
380 BCCI (Bulgaria)
383 SANA (Slovenia)
385 CRO-EAN (Croatia)
387 EAN-BIH (Bosnia-Herzegovina)
400-440 CCG (DE/Germany/Allemagne)
45 + 49 Distribution Code Center - DCC (Japan)
460-469 UNISCAN - EAN Russia (Federation de Russie)
471 CAN Taiwan
474 EAN Estonia
475 EAN Latvia
476 EAN Azerbaijan
477 EAN Lithuania
478 EAN Uzbekistan
479 EAN Sri Lanka
480 PANC Philippines
481 EAN Belarus
482 EAN Ukraine
484 EAN Moldova
485 EAN Armenia
486 EAN Georgia
487 EAN Kazakhstan
489 HKANA Hong Kong
50 E Centre UK - United Kingdom
520 HELLCAN-EAN HELLAS - Greece
528 EAN Lebanon
529 EAN Cyprus
531 EAN-MAC (FYR Macedonia)
535 EAN Malta
539 EAN Ireland
54 ICODIF/EAN Belgium & Luxembourg
560 CODIPOR (Portugal)
569 EAN Iceland/Islande
57 EAN Denmark
590 EAN Poland
594 EAN Romania
599 H.A.P.M.H. (Hungary)
600-601 EAN South Africa
609 EAN Mauritius Island
611 EAN Morocco
613 EAN Algeria
619 Tunicode (Tunisia)
621 EAN Syria
622 EAN Egypt
625 EAN Jordan/Jordanie
626 EAN Iran
628 EAN Saudi Arabia
64 EAN Finland
690-693 ANCC - Article Numbering Centre of China
70 EAN Norge (Norvege)
729 Israeli Bar Code Association - EAN Israel
73 EAN Suede
740 EAN Guatemala
741 EAN El Salvador
742 ICCC (Honduras)
743 EAN Nicaragua
744 EAN Costa Rica Panama
746 746 EAN Republique Dominicaine
750 AMECE (Mexique)
759 EAN Venezuela
76 EAN (Schweiz, Suisse, Svizzera)
770 IAC (Colombie)
773 EAN Uruguay
775 APC - EAN Peru (Perou)
777 EAN Bolivie
779 CODIGO - EAN Argentine
780 EAN Chili
784 EAN Paraguay
786 ECOP (Equateur)
789 EAN Bresil
80 - 83 INDICOD (Italy)
84 AECOC (Espagne)
850 Camera de Comercio de la Republica de Cuba (Cuba)
858 EAN Slovaquie
859 EAN Republique Tcheque
860 EAN YU (Yougoslavie)
867 EAN DPR Korea (Coree du Nord)
869 Union of Chambers of Commerce of Turkey (Turquie)
87 EAN Nederland (Hollande)
880 EAN Korea (Coree du Sud)
885 EAN Thailande
888 SANC (Singapour)
890 EAN Inde
893 EAN Vietnam
899 EAN Indonesie
90 - 91 EAN Autriche
93 EAN Australie
94 EAN Nouvelle Zelande
955 Malaysian Article Numbering Council (MANC) - Malaisie
977 Publications sirielles (ISSN)
978 - 979 Livres (ISBN)
980 Refus de remboursement
981 - 982 Coupons (monnaie courante)
99 Coupons

View File

@ -1,8 +1,12 @@
# File of all ISO-4217 currencies codes
# http://en.wikipedia.org/wiki/ISO_4217
# http://fx.sauder.ubc.ca/currency_table.html for symbols for 2 letter code
#
# Code,Name,Nb decimals
# https://en.wikipedia.org/wiki/ISO_4217
# https://en.wikipedia.org/wiki/Currency_symbol for symbols for 2 letter code
#
# Code, Currency Name, Nb decimals
AED,UAE Dirham,2
AFN,Afghanistan Afghani,2
ALL,Albanian Lek,2

View File

@ -300,7 +300,7 @@ if ($action == 'create') {
// Edit mode
if ($action == 'update') {
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'accounting_account');
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -368,7 +368,7 @@ if ($action == 'create') {
// View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'accounting_account');
dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref');

View File

@ -24,7 +24,7 @@
/**
* \file htdocs/accountancy/admin/export.php
* \ingroup Accountancy (Double entries)
* \brief Setup page to configure accounting expert module
* \brief Setup page to configure accounting export module
*/
require '../../main.inc.php';

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -34,6 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
if (!empty($conf->categorie->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("companies", "compta", "accountancy", "products"));
@ -59,6 +62,8 @@ $account_number_sell = GETPOST('account_number_sell');
$changeaccount = GETPOST('changeaccount', 'array');
$changeaccount_buy = GETPOST('changeaccount_buy', 'array');
$changeaccount_sell = GETPOST('changeaccount_sell', 'array');
$searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0);
$searchCategoryProductList = GETPOST('search_category_product_list', 'array');
$search_ref = GETPOST('search_ref', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
@ -144,6 +149,8 @@ if ($reshook < 0) {
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
$searchCategoryProductOperator = 0;
$searchCategoryProductList = array();
$search_ref = '';
$search_label = '';
$search_desc = '';
@ -283,7 +290,16 @@ $aacompta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUN
$aacompta_prodsell_intra = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef"));
$aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef"));
llxHeader('', $langs->trans("ProductsBinding"));
$title = $langs->trans("ProductsBinding");
$helpurl = '';
$paramsCat = '';
foreach ($searchCategoryProductList as $searchCategoryProduct) {
$paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
}
llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, '');
$pcgverid = getDolGlobalString('CHARTOFACCOUNTS');
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
@ -308,6 +324,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
} else {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'";
}
if (!empty($searchCategoryProductList)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ
}
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if (strlen(trim($search_current_account))) {
$sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, $search_current_account);
@ -318,6 +337,30 @@ if ($search_current_account_valid == 'withoutvalidaccount') {
if ($search_current_account_valid == 'withvalidaccount') {
$sql .= " AND aa.account_number IS NOT NULL";
}
$searchCategoryProductSqlList = array();
if ($searchCategoryProductOperator == 1) {
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL";
} elseif (intval($searchCategoryProduct) > 0) {
$searchCategoryProductSqlList[] = "cp.fk_categorie = ".$db->escape($searchCategoryProduct);
}
}
if (!empty($searchCategoryProductSqlList)) {
$sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
}
} else {
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL";
} elseif (intval($searchCategoryProduct) > 0) {
$searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")";
}
}
if (!empty($searchCategoryProductSqlList)) {
$sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
}
}
// Add search filter like
if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref);
@ -338,6 +381,16 @@ if ($search_onpurchase != '' && $search_onpurchase != '-1') {
$sql .= natural_search('p.tobuy', $search_onpurchase, 1);
}
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
$sql .= " p.fk_product_type,";
$sql .= ' p.tms,';
$sql .= ' aa.rowid,';
if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export";
} else {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export";
}
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
@ -365,11 +418,17 @@ if ($result) {
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($searchCategoryProductOperator == 1) {
$param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator);
}
foreach ($searchCategoryProductList as $searchCategoryProduct) {
$param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
}
if ($search_ref > 0) {
$param .= "&search_desc=".urlencode($search_ref);
$param .= "&search_ref=".urlencode($search_ref);
}
if ($search_label > 0) {
$param .= "&search_desc=".urlencode($search_label);
$param .= "&search_label=".urlencode($search_label);
}
if ($search_desc > 0) {
$param .= "&search_desc=".urlencode($search_desc);
@ -461,6 +520,40 @@ if ($result) {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($chk_prod)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1);
}
// Filter on categories
$moreforfilter = '';
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
$categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1);
$categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -';
$moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300');
$moreforfilter .= ' <input type="checkbox" class="valignmiddle" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ? ' checked="checked"' : '').'/> <span class="none">'.$langs->trans('UseOrOperatorForCategories').'</span>';
$moreforfilter .= '</div>';
}
//Show/hide child products. Hidden by default
if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"' : '').'>';
$moreforfilter .= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>';
$moreforfilter .= '</div>';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if ($moreforfilter) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
print '<div class="div-table-responsive">';
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';

View File

@ -267,7 +267,7 @@ if ($action == "confirm_update") {
if ($mode != '_tmp') {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
$action = 'update';
$action = '';
$id = $object->id;
$piece_num = $object->piece_num;
}
@ -647,6 +647,12 @@ if ($action == 'create') {
print "</tr>\n";
// Empty line is the first line of $object->linesmvt
// So we must get the first line (the empty one) and put it at the end of the array
// in order to display it correctly to the user
$empty_line = array_shift($object->linesmvt);
$object->linesmvt[]= $empty_line;
foreach ($object->linesmvt as $line) {
print '<tr class="oddeven">';
$total_debit += $line->debit;
@ -677,7 +683,33 @@ if ($action == 'create') {
print '<input type="hidden" name="id" value="'.$line->id.'">'."\n";
print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'">';
print '</td>';
} elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) {
if ($action == "" || $action == 'add') {
print '<!-- td columns in add mode -->';
print '<td>';
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
// Also, it is not possible to use a value that is not in the list.
// Also, the label is not automatically filled when a value is selected.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
} else {
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
}
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . $label_operation . '"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
print '<td>';
print '<input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '">';
print '</td>';
}
} else {
print '<!-- td columns in display mode -->';
$resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true);
print '<td>';
if ($resultfetch > 0) {
@ -733,35 +765,6 @@ if ($action == 'create') {
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
}
if (empty($object->date_export) && empty($object->date_validation)) {
if ($action == "" || $action == 'add') {
print '<tr class="oddeven">';
print '<!-- td columns in add mode -->';
print '<td>';
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
// Also, it is not possible to use a value that is not in the list.
// Also, the label is not automatically filled when a value is selected.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
} else {
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
}
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . $label_operation . '"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
print '<td>';
print '<input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '">';
print '</td>';
print '</tr>';
}
}
print '</table>';
print '</div>';

View File

@ -28,6 +28,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@ -42,6 +43,10 @@ $langs->loadLangs(array("accountancy", "compta"));
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist';
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_doc_type = GETPOST("search_doc_type", 'alpha');
$search_doc_ref = GETPOST("search_doc_ref", 'alpha');
@ -86,6 +91,7 @@ $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', '
$search_date_validation_endday = GETPOST('search_date_validation_endday', 'int');
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
$search_import_key = GETPOST("search_import_key", 'alpha');
//var_dump($search_date_start);exit;
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
@ -191,6 +197,7 @@ $arrayfields = array(
't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1),
't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100),
);
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
@ -220,10 +227,12 @@ if (empty($user->rights->accounting->mouvements->lire)) {
* Actions
*/
$param = '';
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') {
$massaction = '';
}
@ -294,10 +303,11 @@ if (empty($reshook)) {
$search_credit = '';
$search_lettering_code = '';
$search_not_reconciled = '';
$search_import_key = '';
$toselect = array();
}
// Must be after the remove filter action, before the export.
$param = '';
$filter = array();
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
@ -416,77 +426,143 @@ if (empty($reshook)) {
$filter['t.reconciled_option'] = $search_not_reconciled;
$param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
}
}
if (!empty($search_import_key)) {
$filter['t.import_key'] = $search_import_key;
$param .= '&search_import_key='.urlencode($search_import_key);
}
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
if (!empty($import_key)) {
$result = $object->deleteByImportkey($import_key);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
//if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
// $delmonth = GETPOST('delmonth', 'int');
// $delyear = GETPOST('delyear', 'int');
// if ($delyear == -1) {
// $delyear = 0;
// }
// $deljournal = GETPOST('deljournal', 'alpha');
// if ($deljournal == -1) {
// $deljournal = 0;
// }
//
// if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
// $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
// if ($result < 0) {
// setEventMessages($object->error, $object->errors, 'errors');
// } else {
// setEventMessages("RecordDeleted", null, 'mesgs');
// }
//
// // Make a redirect to avoid to launch the delete later after a back button
// header("Location: list.php".($param ? '?'.$param : ''));
// exit;
// } else {
// setEventMessages("NoRecordDeleted", null, 'warnings');
// }
//}
if ($action == 'setreexport') {
$setreexport = GETPOST('value', 'int');
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
$error++;
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param ? '?'.$param : ''));
exit;
}
}
if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delmonth = GETPOST('delmonth', 'int');
$delyear = GETPOST('delyear', 'int');
if ($delyear == -1) {
$delyear = 0;
}
$deljournal = GETPOST('deljournal', 'alpha');
if ($deljournal == -1) {
$deljournal = 0;
}
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
if (!$error) {
if ($conf->global->ACCOUNTING_REEXPORT == 1) {
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
} else {
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs');
}
} else {
setEventMessages("RecordDeleted", null, 'mesgs');
setEventMessages($langs->trans("Error"), null, 'errors');
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param ? '?'.$param : ''));
exit;
} else {
setEventMessages("NoRecordDeleted", null, 'warnings');
}
}
if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
header("Location: list.php?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
if ($action == 'setreexport') {
$setreexport = GETPOST('value', 'int');
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
$error++;
}
if (!$error) {
if ($conf->global->ACCOUNTING_REEXPORT == 1) {
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
} else {
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs');
// Mass actions
$objectclass = 'Bookkeeping';
$objectlabel = 'Bookkeeping';
$permissiontoread = $user->rights->societe->lire;
$permissiontodelete = $user->rights->societe->supprimer;
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) {
$nbok = 0;
foreach ($toselect as $toselectid) {
$result = $object->fetch($toselectid);
if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
$result = $object->deleteMvtNum($object->piece_num);
if ($result > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
} elseif ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
}
// Message for elements well deleted
if ($nbok > 1) {
setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
} elseif ($nbok > 0) {
setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
} elseif (!$error) {
setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
}
if (!$error) {
header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
// others mass actions
if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
if ($massaction == 'lettering') {
$lettering = new Lettering($db);
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
if ($nb_lettering < 0) {
setEventMessages('', $lettering->errors, 'errors');
$error++;
$nb_lettering = max(0, abs($nb_lettering) - 2);
} elseif ($nb_lettering == 0) {
$nb_lettering = 0;
setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
}
if ($nb_lettering == 1) {
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
} elseif ($nb_lettering > 1) {
setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
}
if (!$error) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
} elseif ($action == 'unlettering' && $confirm == "yes") {
$lettering = new Lettering($db);
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
if ($nb_lettering < 0) {
setEventMessages('', $lettering->errors, 'errors');
$error++;
$nb_lettering = max(0, abs($nb_lettering) - 2);
} elseif ($nb_lettering == 0) {
$nb_lettering = 0;
setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
}
if ($nb_lettering == 1) {
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
} elseif ($nb_lettering > 1) {
setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
}
if (!$error) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
}
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
@ -520,7 +596,8 @@ $sql .= " t.piece_num,";
$sql .= " t.date_creation,";
$sql .= " t.tms as date_modification,";
$sql .= " t.date_export,";
$sql .= " t.date_validated as date_validation";
$sql .= " t.date_validated as date_validation,";
$sql .= " t.import_key";
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
// Manage filter
$sqlwhere = array();
@ -667,6 +744,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
$num = $db->num_rows($resql);
}
$arrayofselected = is_array($toselect) ? $toselect : array();
// Output page
// --------------------------------------------------------------------
@ -684,7 +762,7 @@ if ($action == 'export_file') {
'name' => 'notifiedexportdate',
'type' => 'checkbox',
'label' => $langs->trans('NotifiedExportDate'),
'value' => $checked,
'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
);
$form_question['separator'] = array('name'=>'separator', 'type'=>'separator');
@ -703,50 +781,46 @@ if ($action == 'export_file') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600);
}
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.urlencode(GETPOST('mvt_num')).$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
}
if ($action == 'delbookkeepingyear') {
$form_question = array();
$delyear = GETPOST('delyear', 'int');
$deljournal = GETPOST('deljournal', 'alpha');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$month_array = array();
for ($i = 1; $i <= 12; $i++) {
$month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
}
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delmonth'] = array(
'name' => 'delmonth',
'type' => 'select',
'label' => $langs->trans('DelMonth'),
'values' => $month_array,
'morecss' => 'minwidth150',
'default' => ''
);
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array(
'name' => 'deljournal',
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'),
'value' => $journal_array,
'default' => $deljournal
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320);
}
//if ($action == 'delbookkeepingyear') {
// $form_question = array();
// $delyear = GETPOST('delyear', 'int');
// $deljournal = GETPOST('deljournal', 'alpha');
//
// if (empty($delyear)) {
// $delyear = dol_print_date(dol_now(), '%Y');
// }
// $month_array = array();
// for ($i = 1; $i <= 12; $i++) {
// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
// }
// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
//
// $form_question['delmonth'] = array(
// 'name' => 'delmonth',
// 'type' => 'select',
// 'label' => $langs->trans('DelMonth'),
// 'values' => $month_array,
// 'morecss' => 'minwidth150',
// 'default' => ''
// );
// $form_question['delyear'] = array(
// 'name' => 'delyear',
// 'type' => 'select',
// 'label' => $langs->trans('DelYear'),
// 'values' => $year_array,
// 'default' => $delyear
// );
// $form_question['deljournal'] = array(
// 'name' => 'deljournal',
// 'type' => 'other', // We don't use select here, the journal_array is already a select html component
// 'label' => $langs->trans('DelJournal'),
// 'value' => $journal_array,
// 'default' => $deljournal
// );
//
// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320);
//}
// Print form confirm
print $formconfirm;
@ -759,6 +833,22 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
// List of mass actions available
$arrayofmassactions = array();
/*
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
$arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering');
$arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering');
}
*/
if ($user->rights->accounting->mouvements->supprimer) {
$arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">';
@ -768,8 +858,7 @@ if ($optioncss != '') {
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">';
print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">';
$massactionbutton = '';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
if (count($filter)) {
$buttonLabel = $langs->trans("ExportFilteredList");
@ -794,7 +883,7 @@ if (empty($reshook)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?type=sub'.$param, '', 1, array('morecss' => 'marginleftonly'));
$url = './card.php?action=create';
if (!empty($socid)) {
@ -805,9 +894,21 @@ if (empty($reshook)) {
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
if ($massaction == 'preunlettering') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1);
} elseif ($massaction == 'predeletebookkeepingwriting') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
}
//$topicmail = "Information";
//$modelmail = "accountingbookkeeping";
//$objecttmp = new BookKeeping($db);
//$trackid = 'bk'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) {
if ($massactionbutton && $contextpage != 'poslist') {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
@ -954,6 +1055,11 @@ if (!empty($arrayfields['t.date_validated']['checked'])) {
print '</div>';
print '</td>';
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="liste_titre center">';
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
print '</td>';
}
// Action column
print '<td class="liste_titre center">';
$searchpicto = $form->showFilterButtons();
@ -1008,6 +1114,9 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
if (!empty($arrayfields['t.date_validated']['checked'])) {
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
@ -1252,17 +1361,21 @@ while ($i < min($num, $limit)) {
}
}
// Action column
print '<td class="nowraponall center">';
if (empty($line->date_export) && empty($line->date_validation)) {
if ($user->rights->accounting->mouvements->creer) {
print '<a class="editfielda paddingleft marginrightonly" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="tdoverflowmax100">'.$obj->import_key."</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
if (empty($line->date_validation)) {
if ($user->rights->accounting->mouvements->supprimer) {
print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&token='.newToken().'&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
// Action column
print '<td class="nowraponall center">';
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($line->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
}
print '</td>';
@ -1283,11 +1396,11 @@ print "</table>";
print '</div>';
// TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>';
}
//if ($user->rights->accounting->mouvements->supprimer_tous) {
// print '<div class="tabsAction tabsActionNoBottom">'."\n";
// print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
// print '</div>';
//}
print '</form>';

View File

@ -28,6 +28,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
@ -39,6 +40,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array("accountancy", "compta"));
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$type = GETPOST('type', 'alpha');
if ($type == 'sub') {
$context_default = 'bookkeepingbysubaccountlist';
} else {
$context_default = 'bookkeepingbyaccountlist';
}
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default;
$search_date_startyear = GETPOST('search_date_startyear', 'int');
$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
$search_date_startday = GETPOST('search_date_startday', 'int');
@ -64,6 +75,7 @@ $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', '
$search_date_validation_endday = GETPOST('search_date_validation_endday', 'int');
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
$search_import_key = GETPOST("search_import_key", 'alpha');
$search_accountancy_code = GETPOST("search_accountancy_code");
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
@ -109,7 +121,7 @@ if ($sortfield == "") {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new BookKeeping($db);
$formfile = new FormFile($db);
$hookmanager->initHooks(array('bookkeepingbyaccountlist'));
$hookmanager->initHooks(array($context_default));
$formaccounting = new FormAccounting($db);
$form = new Form($db);
@ -153,6 +165,7 @@ $arrayfields = array(
't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100),
);
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
@ -187,10 +200,13 @@ if (empty($user->rights->accounting->mouvements->lire)) {
* Action
*/
$param = '';
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
$action = 'list';
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') {
$massaction = '';
}
@ -242,10 +258,11 @@ if (empty($reshook)) {
$search_credit = '';
$search_lettering_code = '';
$search_not_reconciled = '';
$search_import_key = '';
$toselect = array();
}
// Must be after the remove filter action, before the export.
$param = '';
$filter = array();
if (!empty($search_date_start)) {
@ -261,12 +278,20 @@ if (empty($reshook)) {
$param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int');
}
if (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
if ($type == 'sub') {
$filter['t.subledger_account>='] = $search_accountancy_code_start;
} else {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
}
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
}
if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
if ($type == 'sub') {
$filter['t.subledger_account<='] = $search_accountancy_code_end;
} else {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
}
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
}
if (!empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account;
@ -326,61 +351,133 @@ if (empty($reshook)) {
$filter['t.date_validated<='] = $search_date_validation_end;
$param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear;
}
}
if (!empty($search_import_key)) {
$filter['t.import_key'] = $search_import_key;
$param .= '&search_import_key='.urlencode($search_import_key);
}
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
// param with type of list
$url_param = substr($param, 1); // remove first "&"
if (!empty($type)) {
$param = '&type='.$type.$param;
}
if (!empty($import_key)) {
$result = $object->deleteByImportkey($import_key);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
//if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
// $delmonth = GETPOST('delmonth', 'int');
// $delyear = GETPOST('delyear', 'int');
// if ($delyear == -1) {
// $delyear = 0;
// }
// $deljournal = GETPOST('deljournal', 'alpha');
// if ($deljournal == -1) {
// $deljournal = 0;
// }
//
// if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
// $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
// if ($result < 0) {
// setEventMessages($object->error, $object->errors, 'errors');
// } else {
// setEventMessages("RecordDeleted", null, 'mesgs');
// }
//
// // Make a redirect to avoid to launch the delete later after a back button
// header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
// exit;
// } else {
// setEventMessages("NoRecordDeleted", null, 'warnings');
// }
//}
// Mass actions
$objectclass = 'Bookkeeping';
$objectlabel = 'Bookkeeping';
$permissiontoread = $user->rights->societe->lire;
$permissiontodelete = $user->rights->societe->supprimer;
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) {
$nbok = 0;
foreach ($toselect as $toselectid) {
$result = $object->fetch($toselectid);
if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
$result = $object->deleteMvtNum($object->piece_num);
if ($result > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
} elseif ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit;
}
}
if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delmonth = GETPOST('delmonth', 'int');
$delyear = GETPOST('delyear', 'int');
if ($delyear == -1) {
$delyear = 0;
}
$deljournal = GETPOST('deljournal', 'alpha');
if ($deljournal == -1) {
$deljournal = 0;
}
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages("RecordDeleted", null, 'mesgs');
// Message for elements well deleted
if ($nbok > 1) {
setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
} elseif ($nbok > 0) {
setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
} elseif (!$error) {
setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit;
} else {
setEventMessages("NoRecordDeleted", null, 'warnings');
}
}
if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
if (!$error) {
header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
exit;
// others mass actions
if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
if ($massaction == 'lettering') {
$lettering = new Lettering($db);
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
if ($nb_lettering < 0) {
setEventMessages('', $lettering->errors, 'errors');
$error++;
$nb_lettering = max(0, abs($nb_lettering) - 2);
} elseif ($nb_lettering == 0) {
$nb_lettering = 0;
setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
}
if ($nb_lettering == 1) {
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
} elseif ($nb_lettering > 1) {
setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
}
if (!$error) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
} elseif ($action == 'unlettering' && $confirm == "yes") {
$lettering = new Lettering($db);
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
if ($nb_lettering < 0) {
setEventMessages('', $lettering->errors, 'errors');
$error++;
$nb_lettering = max(0, abs($nb_lettering) - 2);
} elseif ($nb_lettering == 0) {
$nb_lettering = 0;
setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
}
if ($nb_lettering == 1) {
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
} elseif ($nb_lettering > 1) {
setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
}
if (!$error) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
}
}
}
@ -394,73 +491,101 @@ $formfile = new FormFile($db);
$formother = new FormOther($db);
$form = new Form($db);
$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("Bookkeeping").')';
$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' (';
if ($type == 'sub') {
$title_page .= $langs->trans("BookkeepingSubAccount");
} else {
$title_page .= $langs->trans("Bookkeeping");
}
$title_page .= ')';
llxHeader('', $title_page);
// List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
if ($type == 'sub') {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1);
} else {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
}
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter);
if ($type == 'sub') {
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
} else {
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter);
}
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$arrayofselected = is_array($toselect) ? $toselect : array();
$num = count($object->lines);
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
///if ($action == 'delbookkeepingyear') {
// $form_question = array();
// $delyear = GETPOST('delyear', 'int');
// $deljournal = GETPOST('deljournal', 'alpha');
//
// if (empty($delyear)) {
// $delyear = dol_print_date(dol_now(), '%Y');
// }
// $month_array = array();
// for ($i = 1; $i <= 12; $i++) {
// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
// }
// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
//
// $form_question['delmonth'] = array(
// 'name' => 'delmonth',
// 'type' => 'select',
// 'label' => $langs->trans('DelMonth'),
// 'values' => $month_array,
// 'default' => ''
// );
// $form_question['delyear'] = array(
// 'name' => 'delyear',
// 'type' => 'select',
// 'label' => $langs->trans('DelYear'),
// 'values' => $year_array,
// 'default' => $delyear
// );
// $form_question['deljournal'] = array(
// 'name' => 'deljournal',
// 'type' => 'other', // We don't use select here, the journal_array is already a select html component
// 'label' => $langs->trans('DelJournal'),
// 'value' => $journal_array,
// 'default' => $deljournal
// );
//
// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
//}
// Print form confirm
print $formconfirm;
// List of mass actions available
$arrayofmassactions = array();
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
$arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering');
$arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering');
}
if ($action == 'delbookkeepingyear') {
$form_question = array();
$delyear = GETPOST('delyear', 'int');
$deljournal = GETPOST('deljournal', 'alpha');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$month_array = array();
for ($i = 1; $i <= 12; $i++) {
$month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
}
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delmonth'] = array(
'name' => 'delmonth',
'type' => 'select',
'label' => $langs->trans('DelMonth'),
'values' => $month_array,
'default' => ''
);
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array(
'name' => 'deljournal',
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'),
'value' => $journal_array,
'default' => $deljournal
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
print $formconfirm;
if ($user->rights->accounting->mouvements->supprimer) {
$arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -469,15 +594,22 @@ if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
if ($type == 'sub') {
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
} else {
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly'));
}
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
}
@ -488,11 +620,29 @@ 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, $newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
if ($massaction == 'preunlettering') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1);
} elseif ($massaction == 'predeletebookkeepingwriting') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
}
//DeleteMvt=Supprimer des lignes d'opérations de la comptabilité
//DelMonth=Mois à effacer
//DelYear=Année à supprimer
//DelJournal=Journal à supprimer
//ConfirmDeleteMvt=Cette action supprime les lignes des opérations pour l'année/mois et/ou pour le journal sélectionné (au moins un critère est requis). Vous devrez utiliser de nouveau la fonctionnalité '%s' pour retrouver vos écritures dans la comptabilité.
//ConfirmDeleteMvtPartial=Cette action supprime l'écriture de la comptabilité (toutes les lignes opérations liées à une même écriture seront effacées).
//$topicmail = "Information";
//$modelmail = "accountingbookkeeping";
//$objecttmp = new BookKeeping($db);
//$trackid = 'bk'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) {
if ($massactionbutton && $contextpage != 'poslist') {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
@ -503,15 +653,28 @@ if (preg_match('/^asc/i', $sortorder)) {
$sortorder = "desc";
}
// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines)
if ($type == 'sub') {
print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
}
$moreforfilter = '';
// Accountancy account
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('AccountAccounting').': ';
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200');
if ($type == 'sub') {
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200');
} else {
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200');
}
$moreforfilter .= ' ';
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200');
if ($type == 'sub') {
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200');
} else {
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200');
}
$moreforfilter .= '</div>';
$moreforfilter .= '</div>';
@ -599,6 +762,11 @@ if (!empty($arrayfields['t.date_validated']['checked'])) {
print '</div>';
print '</td>';
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="liste_titre center">';
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
print '</td>';
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
@ -643,6 +811,9 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
if (!empty($arrayfields['t.date_validated']['checked'])) {
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
@ -667,7 +838,11 @@ while ($i < min($num, $limit)) {
$total_debit += $line->debit;
$total_credit += $line->credit;
$accountg = length_accountg($line->numero_compte);
if ($type == 'sub') {
$accountg = length_accounta($line->subledger_account);
} else {
$accountg = length_accountg($line->numero_compte);
}
//if (empty($accountg)) $accountg = '-';
$colspan = 0; // colspan before field 'label of operation'
@ -686,7 +861,11 @@ while ($i < min($num, $limit)) {
// Show a subtotal by accounting account
if (isset($displayed_account_number)) {
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.length_accountg($displayed_account_number).':</td>';
if ($type == 'sub') {
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accounta($displayed_account_number) . ':</td>';
} else {
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':</td>';
}
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
@ -712,11 +891,28 @@ while ($i < min($num, $limit)) {
// Show the break account
print '<tr class="trforbreak">';
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 10).'" class="tdforbreak">';
if ($line->numero_compte != "" && $line->numero_compte != '-1') {
print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte);
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : count($arrayfields)+1).'" class="tdforbreak">';
if ($type == 'sub') {
if ($line->subledger_account != "" && $line->subledger_account != '-1') {
print $line->subledger_label . ' : ' . length_accounta($line->subledger_account);
} else {
// Should not happen: subledger account must be null or a non empty value
print '<span class="error">' . $langs->trans("Unknown");
if ($line->subledger_label) {
print ' (' . $line->subledger_label . ')';
$htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
} else {
$htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel';
}
print $form->textwithpicto('', $htmltext);
print '</span>';
}
} else {
print '<span class="error">'.$langs->trans("Unknown").'</span>';
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>';
}
}
print '</td>';
print '</tr>';
@ -890,22 +1086,26 @@ while ($i < min($num, $limit)) {
}
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="tdoverflowmax100">'.$line->import_key."</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$line);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowraponall center">';
if (empty($line->date_export) && empty($line->date_validation)) {
if ($user->rights->accounting->mouvements->creer) {
print '<a class="editfielda paddingleft marginrightonly" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
}
}
if (empty($line->date_validation)) {
if ($user->rights->accounting->mouvements->supprimer) {
print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&token='.newToken().'&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($line->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
}
print '</td>';
if (!$i) {
@ -955,11 +1155,11 @@ print "</table>";
print '</div>';
// TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>';
}
//if ($user->rights->accounting->mouvements->supprimer_tous) {
// print '<div class="tabsAction tabsActionNoBottom">'."\n";
// print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
// print '</div>';
//}
print '</form>';

View File

@ -1,979 +0,0 @@
<?php
/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2020 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/bookkeeping/listbysubaccount.php
* \ingroup Accountancy (Double entries)
* \brief List operation of ledger ordered by subaccount number
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy", "compta"));
$action = GETPOST('action', 'aZ09');
$search_date_startyear = GETPOST('search_date_startyear', 'int');
$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
$search_date_startday = GETPOST('search_date_startday', 'int');
$search_date_endyear = GETPOST('search_date_endyear', 'int');
$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
$search_date_endday = GETPOST('search_date_endday', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_date_export_startyear = GETPOST('search_date_export_startyear', 'int');
$search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int');
$search_date_export_startday = GETPOST('search_date_export_startday', 'int');
$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int');
$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int');
$search_date_export_endday = GETPOST('search_date_export_endday', 'int');
$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
$search_date_validation_startyear = GETPOST('search_date_validation_startyear', 'int');
$search_date_validation_startmonth = GETPOST('search_date_validation_startmonth', 'int');
$search_date_validation_startday = GETPOST('search_date_validation_startday', 'int');
$search_date_validation_endyear = GETPOST('search_date_validation_endyear', 'int');
$search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', 'int');
$search_date_validation_endday = GETPOST('search_date_validation_endday', 'int');
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
$search_accountancy_code = GETPOST("search_accountancy_code");
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
if ($search_accountancy_code_start == - 1) {
$search_accountancy_code_start = '';
}
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
if ($search_accountancy_code_end == - 1) {
$search_accountancy_code_end = '';
}
$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'array');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
$action = 'delbookkeepingyear';
}
// Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") {
$sortorder = "ASC";
}
if ($sortfield == "") {
$sortfield = "t.doc_date,t.rowid";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new BookKeeping($db);
$formfile = new FormFile($db);
$hookmanager->initHooks(array('bookkeepingbysubaccountlist'));
$formaccounting = new FormAccounting($db);
$form = new Form($db);
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 .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql .= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1) {
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
}
}
$arrayfields = array(
// 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
);
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
unset($arrayfields['t.lettering_code']);
}
if ($search_date_start && empty($search_date_startyear)) {
$tmparray = dol_getdate($search_date_start);
$search_date_startyear = $tmparray['year'];
$search_date_startmonth = $tmparray['mon'];
$search_date_startday = $tmparray['mday'];
}
if ($search_date_end && empty($search_date_endyear)) {
$tmparray = dol_getdate($search_date_end);
$search_date_endyear = $tmparray['year'];
$search_date_endmonth = $tmparray['mon'];
$search_date_endday = $tmparray['mday'];
}
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->socid > 0) {
accessforbidden();
}
if (empty($user->rights->accounting->mouvements->lire)) {
accessforbidden();
}
/*
* Action
*/
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_doc_date = '';
$search_accountancy_code = '';
$search_accountancy_code_start = '';
$search_accountancy_code_end = '';
$search_label_account = '';
$search_doc_ref = '';
$search_label_operation = '';
$search_mvt_num = '';
$search_direction = '';
$search_ledger_code = array();
$search_date_start = '';
$search_date_end = '';
$search_date_startyear = '';
$search_date_startmonth = '';
$search_date_startday = '';
$search_date_endyear = '';
$search_date_endmonth = '';
$search_date_endday = '';
$search_date_export_start = '';
$search_date_export_end = '';
$search_date_export_startyear = '';
$search_date_export_startmonth = '';
$search_date_export_startday = '';
$search_date_export_endyear = '';
$search_date_export_endmonth = '';
$search_date_export_endday = '';
$search_date_validation_start = '';
$search_date_validation_end = '';
$search_date_validation_startyear = '';
$search_date_validation_startmonth = '';
$search_date_validation_startday = '';
$search_date_validation_endyear = '';
$search_date_validation_endmonth = '';
$search_date_validation_endday = '';
$search_debit = '';
$search_credit = '';
$search_lettering_code = '';
$search_not_reconciled = '';
}
// Must be after the remove filter action, before the export.
$param = '';
$filter = array();
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
}
if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear;
}
if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int');
}
if (!empty($search_accountancy_code_start)) {
$filter['t.subledger_account>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
}
if (!empty($search_accountancy_code_end)) {
$filter['t.subledger_account<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
}
if (!empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account;
$param .= '&search_label_compte='.urlencode($search_label_account);
}
if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num='.urlencode($search_mvt_num);
}
if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
}
if (!empty($search_label_operation)) {
$filter['t.label_operation'] = $search_label_operation;
$param .= '&search_label_operation='.urlencode($search_label_operation);
}
if (!empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$param .= '&search_direction='.urlencode($search_direction);
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
foreach ($search_ledger_code as $code) {
$param .= '&search_ledger_code[]='.urlencode($code);
}
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit='.urlencode($search_debit);
}
if (!empty($search_credit)) {
$filter['t.credit'] = $search_credit;
$param .= '&search_credit='.urlencode($search_credit);
}
if (!empty($search_lettering_code)) {
$filter['t.lettering_code'] = $search_lettering_code;
$param .= '&search_lettering_code='.urlencode($search_lettering_code);
}
if (!empty($search_not_reconciled)) {
$filter['t.reconciled_option'] = $search_not_reconciled;
$param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
}
if (!empty($search_date_export_start)) {
$filter['t.date_export>='] = $search_date_export_start;
$param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear;
}
if (!empty($search_date_export_end)) {
$filter['t.date_export<='] = $search_date_export_end;
$param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear;
}
if (!empty($search_date_validation_start)) {
$filter['t.date_validated>='] = $search_date_validation_start;
$param .= '&search_date_validation_startmonth='.$search_date_validation_startmonth.'&search_date_validation_startday='.$search_date_validation_startday.'&search_date_validation_startyear='.$search_date_validation_startyear;
}
if (!empty($search_date_validation_end)) {
$filter['t.date_validated<='] = $search_date_validation_end;
$param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear;
}
}
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
if (!empty($import_key)) {
$result = $object->deleteByImportkey($import_key);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit;
}
}
if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delmonth = GETPOST('delmonth', 'int');
$delyear = GETPOST('delyear', 'int');
if ($delyear == -1) {
$delyear = 0;
}
$deljournal = GETPOST('deljournal', 'alpha');
if ($deljournal == -1) {
$deljournal = 0;
}
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages("RecordDeleted", null, 'mesgs');
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit;
} else {
setEventMessages("NoRecordDeleted", null, 'warnings');
}
}
if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
/*
* View
*/
$formaccounting = new FormAccounting($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
$form = new Form($db);
$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')';
llxHeader('', $title_page);
// List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$num = count($object->lines);
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
}
if ($action == 'delbookkeepingyear') {
$form_question = array();
$delyear = GETPOST('delyear', 'int');
$deljournal = GETPOST('deljournal', 'alpha');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$month_array = array();
for ($i = 1; $i <= 12; $i++) {
$month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
}
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delmonth'] = array(
'name' => 'delmonth',
'type' => 'select',
'label' => $langs->trans('DelMonth'),
'values' => $month_array,
'default' => ''
);
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array(
'name' => 'deljournal',
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'),
'value' => $journal_array,
'default' => $deljournal
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
print $formconfirm;
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
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, $newcardbutton, '', $limit, 0, 0, 1);
print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
// Reverse sort order
if (preg_match('/^asc/i', $sortorder)) {
$sortorder = "asc";
} else {
$sortorder = "desc";
}
$moreforfilter = '';
// Accountancy account
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('AccountAccounting').': ';
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200');
$moreforfilter .= ' ';
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200');
$moreforfilter .= '</div>';
$moreforfilter .= '</div>';
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste centpercent">';
// Filters lines
print '<tr class="liste_titre_filter">';
// Movement number
if (!empty($arrayfields['t.piece_num']['checked'])) {
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
}
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
print '<td class="liste_titre center">';
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
print '</td>';
}
// Date document
if (!empty($arrayfields['t.doc_date']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
// Ref document
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
}
// Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) {
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
}
// Debit
if (!empty($arrayfields['t.debit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
}
// Credit
if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
}
// Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print '<td class="liste_titre center">';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
print '</td>';
}
// Date export
if (!empty($arrayfields['t.date_export']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
// Date validation
if (!empty($arrayfields['t.date_validated']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="liste_titre center">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['t.piece_num']['checked'])) {
print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['t.code_journal']['checked'])) {
print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.doc_date']['checked'])) {
print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.label_operation']['checked'])) {
print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.debit']['checked'])) {
print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.credit']['checked'])) {
print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.date_export']['checked'])) {
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.date_validated']['checked'])) {
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$total_debit = 0;
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < min($num, $limit)) {
$line = $object->lines[$i];
$total_debit += $line->debit;
$total_credit += $line->credit;
$accountg = length_accounta($line->subledger_account);
//if (empty($accountg)) $accountg = '-';
$colspan = 0; // colspan before field 'label of operation'
$colspanend = 3; // colspan after debit/credit
if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; }
if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; }
if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; }
if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; }
if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; }
if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
// Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
// Show a subtotal by accounting account
if (isset($displayed_account_number)) {
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0) {
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
// Show the break account
print '<tr class="trforbreak">';
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 10).'" class="tdforbreak">';
if ($line->subledger_account != "" && $line->subledger_account != '-1') {
print $line->subledger_label.' : '.length_accounta($line->subledger_account);
} else {
// Should not happen: subledger account must be null or a non empty value
print '<span class="error">'.$langs->trans("Unknown");
if ($line->subledger_label) {
print ' ('.$line->subledger_label.')';
$htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
} else {
$htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel';
}
print $form->textwithpicto('', $htmltext);
print '</span>';
}
print '</td>';
print '</tr>';
$displayed_account_number = $accountg;
//if (empty($displayed_account_number)) $displayed_account_number='-';
$sous_total_debit = 0;
$sous_total_credit = 0;
$colspan = 0;
}
print '<tr class="oddeven">';
// Piece number
if (!empty($arrayfields['t.piece_num']['checked'])) {
print '<td>';
$object->id = $line->id;
$object->piece_num = $line->piece_num;
print $object->getNomUrl(1, '', 0, '', 1);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Journal code
if (!empty($arrayfields['t.code_journal']['checked'])) {
$accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $line->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
print '<td class="center">'.$journaltoshow.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Document date
if (!empty($arrayfields['t.doc_date']['checked'])) {
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Document ref
if (!empty($arrayfields['t.doc_ref']['checked'])) {
if ($line->doc_type == 'customer_invoice') {
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$objectstatic = new Facture($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'facture';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'supplier_invoice') {
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$objectstatic = new FactureFournisseur($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'invoice_supplier';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} elseif ($line->doc_type == 'expense_report') {
$langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$objectstatic = new ExpenseReport($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'expensereport';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank') {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc);
} else {
// Other type
}
print '<td class="maxwidth400">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref
print '<td class="nobordernopadding">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink;
} elseif ($line->doc_type == 'bank') {
print $objectstatic->getNomUrl(1);
$bank_ref = strstr($line->doc_ref, '-');
print " " . $bank_ref;
} else {
print $line->doc_ref;
}
print '</td></tr></table>';
print "</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) {
// Affiche un lien vers la facture client/fournisseur
$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>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Amount debit
if (!empty($arrayfields['t.debit']['checked'])) {
print '<td class="right nowraponall amount">'.($line->debit ? price($line->debit) : '').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
}
$totalarray['val']['totaldebit'] += $line->debit;
}
// Amount credit
if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="right nowraponall amount">'.($line->credit ? price($line->credit) : '').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
}
$totalarray['val']['totalcredit'] += $line->credit;
}
// Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print '<td class="center">'.$line->lettering_code.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Exported operation date
if (!empty($arrayfields['t.date_export']['checked'])) {
print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Validated operation date
if (!empty($arrayfields['t.date_validated']['checked'])) {
print '<td class="center">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowraponall center">';
if (empty($line->date_export) && empty($line->date_validation)) {
if ($user->rights->accounting->mouvements->creer) {
print '<a class="editfielda paddingleft marginrightonly" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
}
}
if (empty($line->date_validation)) {
if ($user->rights->accounting->mouvements->supprimer) {
print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&token='.newToken().'&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
}
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
// Comptabilise le sous-total
$sous_total_debit += $line->debit;
$sous_total_credit += $line->credit;
print "</tr>\n";
$i++;
}
if ($num > 0 && $colspan > 0) {
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0) {
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "</table>";
print '</div>';
// TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>';
}
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -980,6 +980,8 @@ class AccountancyExport
print dol_string_unaccent($date_creation) . $separator;
// FEC:EcritureLib
// Clean label operation to prevent problem on export with tab separator & other character
$line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
print dol_string_unaccent($line->label_operation) . $separator;
// FEC:Debit
@ -1007,6 +1009,8 @@ class AccountancyExport
print $date_limit_payment . $separator;
// FEC_suppl:NumFacture
// Clean ref invoice to prevent problem on export with tab separator & other character
$refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
print $end_line;
@ -1107,6 +1111,8 @@ class AccountancyExport
print $date_document . $separator;
// FEC:EcritureLib
// Clean label operation to prevent problem on export with tab separator & other character
$line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
print dol_string_unaccent($line->label_operation) . $separator;
// FEC:Debit
@ -1134,6 +1140,8 @@ class AccountancyExport
print $date_limit_payment . $separator;
// FEC_suppl:NumFacture
// Clean ref invoice to prevent problem on export with tab separator & other character
$refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
@ -1712,6 +1720,8 @@ class AccountancyExport
print self::trunc($line->label_compte, 60).$separator; //Account label
print self::trunc($line->doc_ref, 20).$separator; //Piece
// Clean label operation to prevent problem on export with tab separator & other character
$line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
print self::trunc($line->label_operation, 60).$separator; //Operation label
print price(abs($line->debit - $line->credit)).$separator; //Amount
print $line->sens.$separator; //Direction

View File

@ -852,7 +852,8 @@ class BookKeeping extends CommonObject
$sql .= " t.piece_num,";
$sql .= " t.date_creation,";
$sql .= " t.date_export,";
$sql .= " t.date_validated as date_validation";
$sql .= " t.date_validated as date_validation,";
$sql .= " t.import_key";
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
@ -947,6 +948,7 @@ class BookKeeping extends CommonObject
$line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_export = $this->db->jdate($obj->date_export);
$line->date_validation = $this->db->jdate($obj->date_validation);
$line->import_key = $obj->import_key;
$this->lines[] = $line;

View File

@ -33,6 +33,12 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
*/
class Lettering extends BookKeeping
{
/**
* @var BookKeeping[] Bookkeeping cached
*/
public static $bookkeeping_cached = array();
/**
* letteringThirdparty
*
@ -119,6 +125,7 @@ class Lettering extends BookKeeping
$ids[$obj2->rowid] = $obj2->rowid;
$ids_fact[] = $obj2->fact_id;
}
$this->db->free($resql2);
} else {
$this->errors[] = $this->db->lasterror;
return -1;
@ -146,6 +153,7 @@ class Lettering extends BookKeeping
while ($obj2 = $this->db->fetch_object($resql2)) {
$ids[$obj2->rowid] = $obj2->rowid;
}
$this->db->free($resql2);
} else {
$this->errors[] = $this->db->lasterror;
return -1;
@ -205,6 +213,7 @@ class Lettering extends BookKeeping
while ($obj2 = $this->db->fetch_object($resql2)) {
$ids[$obj2->rowid] = $obj2->rowid;
}
$this->db->free($resql2);
} else {
$this->errors[] = $this->db->lasterror;
return -1;
@ -216,6 +225,7 @@ class Lettering extends BookKeeping
$result = $this->updateLettering($ids);
}
}
$this->db->free($resql);
}
if ($error) {
foreach ($this->errors as $errmsg) {
@ -230,17 +240,31 @@ class Lettering extends BookKeeping
/**
*
* @param array $ids ids array
* @param boolean $notrigger no trigger
* @return number
* @param array $ids ids array
* @param boolean $notrigger no trigger
* @return int
*/
public function updateLettering($ids = array(), $notrigger = false)
{
$error = 0;
$lettre = 'AAA';
$sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1";
$sql = "SELECT DISTINCT ab2.lettering_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping As ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu2 ON bu2.url_id = bu.url_id";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.fk_doc = bu2.fk_bank";
$sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")";
$sql .= " AND ab.doc_type = 'bank'";
$sql .= " AND ab2.doc_type = 'bank'";
$sql .= " AND bu.type = 'company'";
$sql .= " AND bu2.type = 'company'";
$sql .= " AND ab.subledger_account != ''";
$sql .= " AND ab2.subledger_account != ''";
$sql .= " AND ab.lettering_code IS NULL";
$sql .= " AND ab2.lettering_code != ''";
$sql .= " ORDER BY ab2.lettering_code DESC";
$sql .= " LIMIT 1 ";
$result = $this->db->query($sql);
if ($result) {
@ -249,13 +273,14 @@ class Lettering extends BookKeeping
if (!empty($obj->lettering_code)) {
$lettre++;
}
$this->db->free($result);
} else {
$this->errors[] = 'Error'.$this->db->lasterror();
$error++;
}
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL";
$sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''";
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
@ -263,6 +288,7 @@ class Lettering extends BookKeeping
$this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2);
$error++;
}
$this->db->free($result);
} else {
$this->errors[] = 'Erreur sql'.$this->db->lasterror();
$error++;
@ -276,8 +302,7 @@ class Lettering extends BookKeeping
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql .= " lettering_code='".$this->db->escape($lettre)."'";
$sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false
$sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL ";
$this->db->begin();
$sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''";
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -293,11 +318,429 @@ class Lettering extends BookKeeping
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
*
* @param array $ids ids array
* @param boolean $notrigger no trigger
* @return int
*/
public function deleteLettering($ids, $notrigger = false)
{
$error = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql .= " lettering_code = NULL";
$sql .= " , date_lettering = NULL";
$sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).")";
$sql .= " AND subledger_account != ''";
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
return -1 * $error;
} else {
return 1;
}
}
/**
* Lettering bookkeeping lines all types
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $unlettering Do unlettering
* @return int <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered)
*/
public function bookkeepingLetteringAll($bookkeeping_ids, $unlettering = false)
{
dol_syslog(__METHOD__ . " - ", LOG_DEBUG);
$error = 0;
$errors = array();
$nb_lettering = 0;
$result = $this->bookkeepingLettering($bookkeeping_ids, 'customer_invoice', $unlettering);
if ($result < 0) {
$error++;
$errors = array_merge($errors, $this->errors);
$nb_lettering += abs($result) - 2;
} else {
$nb_lettering += $result;
}
$result = $this->bookkeepingLettering($bookkeeping_ids, 'supplier_invoice', $unlettering);
if ($result < 0) {
$error++;
$errors = array_merge($errors, $this->errors);
$nb_lettering += abs($result) - 2;
} else {
$nb_lettering += $result;
}
if ($error) {
$this->errors = $errors;
return -2 - $nb_lettering;
} else {
return $nb_lettering;
}
}
/**
* Lettering bookkeeping lines
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice')
* @param bool $unlettering Do unlettering
* @return int <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered)
*/
public function bookkeepingLettering($bookkeeping_ids, $type = 'customer_invoice', $unlettering = false)
{
global $langs;
$this->errors = array();
// Clean parameters
$bookkeeping_ids = is_array($bookkeeping_ids) ? $bookkeeping_ids : array();
$type = trim($type);
$error = 0;
$nb_lettering = 0;
$grouped_lines = $this->getLinkedLines($bookkeeping_ids, $type);
foreach ($grouped_lines as $lines) {
$group_error = 0;
$total = 0;
$do_it = !$unlettering;
$lettering_code = null;
$piece_num_lines = array();
$bookkeeping_lines = array();
foreach ($lines as $line_infos) {
$bookkeeping_lines[$line_infos['id']] = $line_infos['id'];
$piece_num_lines[$line_infos['piece_num']] = $line_infos['piece_num'];
$total += ($line_infos['credit'] > 0 ? $line_infos['credit'] : -$line_infos['debit']);
// Check lettering code
if ($unlettering) {
if (isset($lettering_code) && $lettering_code != $line_infos['lettering_code']) {
$this->errors[] = $langs->trans('AccountancyErrorMismatchLetteringCode');
$group_error++;
break;
}
if (!isset($lettering_code)) $lettering_code = (string) $line_infos['lettering_code'];
if (!empty($line_infos['lettering_code'])) $do_it = true;
} elseif (!empty($line_infos['lettering_code'])) $do_it = false;
}
// Check balance amount
if (!$group_error && !$unlettering && price2num($total) != 0) {
$this->errors[] = $langs->trans('AccountancyErrorMismatchBalanceAmount', $total);
$group_error++;
}
// Lettering/Unlettering the group of bookkeeping lines
if (!$group_error && $do_it) {
if ($unlettering) $result = $this->deleteLettering($bookkeeping_lines);
else $result = $this->updateLettering($bookkeeping_lines);
if ($result < 0) {
$group_error++;
} else {
$nb_lettering++;
}
}
if ($group_error) {
$this->errors[] = $langs->trans('AccountancyErrorLetteringBookkeeping', implode(', ', $piece_num_lines));
$error++;
}
}
if ($error) {
return -2 - $nb_lettering;
} else {
return $nb_lettering;
}
}
/**
* Lettering bookkeeping lines
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice')
* @return array|int <0 if error otherwise all linked lines by block
*/
public function getLinkedLines($bookkeeping_ids, $type = 'customer_invoice')
{
global $conf, $langs;
$this->errors = array();
// Clean parameters
$bookkeeping_ids = is_array($bookkeeping_ids) ? $bookkeeping_ids : array();
$type = trim($type);
if ($type == 'customer_invoice') {
$doc_type = 'customer_invoice';
$bank_url_type = 'payment';
$payment_element = 'paiement_facture';
$fk_payment_element = 'fk_paiement';
$fk_element = 'fk_facture';
$account_number = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
} elseif ($type == 'supplier_invoice') {
$doc_type = 'supplier_invoice';
$bank_url_type = 'payment_supplier';
$payment_element = 'paiementfourn_facturefourn';
$fk_payment_element = 'fk_paiementfourn';
$fk_element = 'fk_facturefourn';
$account_number = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
} else {
$langs->load('errors');
$this->errors[] = $langs->trans('ErrorBadParameters');
return -1;
}
$payment_ids = array();
// Get all payment id from bank lines
$sql = "SELECT DISTINCT bu.url_id AS payment_id";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc";
$sql .= " WHERE ab.doc_type = 'bank'";
// $sql .= " AND ab.subledger_account != ''";
// $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'";
$sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'";
if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")";
dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->errors[] = "Error " . $this->db->lasterror();
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$payment_ids[$obj->payment_id] = $obj->payment_id;
}
$this->db->free($resql);
// Get all payment id from payment lines
$sql = "SELECT DISTINCT pe.$fk_payment_element AS payment_id";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc";
$sql .= " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'";
// $sql .= " AND ab.subledger_account != ''";
// $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'";
$sql .= " AND pe.$fk_payment_element IS NOT NULL";
if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")";
dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->errors[] = "Error " . $this->db->lasterror();
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$payment_ids[$obj->payment_id] = $obj->payment_id;
}
$this->db->free($resql);
if (empty($payment_ids)) {
return array();
}
// Get all payments linked by group
$payment_by_group = $this->getLinkedPaymentByGroup($payment_ids, $type);
$groups = array();
foreach ($payment_by_group as $payment_list) {
$lines = array();
// Get bank lines
$sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank_url AS bu";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = bu.fk_bank";
$sql .= " WHERE bu.url_id IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")";
$sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'";
$sql .= " AND ab.doc_type = 'bank'";
$sql .= " AND ab.subledger_account != ''";
$sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'";
dol_syslog(__METHOD__ . " - Get bank lines", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->errors[] = "Error " . $this->db->lasterror();
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$lines[$obj->rowid] = array('id' => $obj->rowid, 'piece_num' => $obj->piece_num, 'lettering_code' => $obj->lettering_code, 'debit' => $obj->debit, 'credit' => $obj->credit);
}
$this->db->free($resql);
// Get payment lines
$sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit";
$sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = pe.$fk_element";
$sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")";
$sql .= " AND ab.doc_type = '" . $this->db->escape($doc_type) . "'";
$sql .= " AND ab.subledger_account != ''";
$sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'";
dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->errors[] = "Error " . $this->db->lasterror();
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$lines[$obj->rowid] = array('id' => $obj->rowid, 'piece_num' => $obj->piece_num, 'lettering_code' => $obj->lettering_code, 'debit' => $obj->debit, 'credit' => $obj->credit);
}
$this->db->free($resql);
if (!empty($lines)) {
$groups[] = $lines;
}
}
return $groups;
}
/**
* Linked payment by group
*
* @param array $payment_ids list of payment id
* @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice')
* @return array|int <0 if error otherwise all linked lines by block
*/
public function getLinkedPaymentByGroup($payment_ids, $type)
{
global $langs;
// Clean parameters
$payment_ids = is_array($payment_ids) ? $payment_ids : array();
$type = trim($type);
if (empty($payment_ids)) {
return array();
}
if ($type == 'customer_invoice') {
$payment_element = 'paiement_facture';
$fk_payment_element = 'fk_paiement';
$fk_element = 'fk_facture';
} elseif ($type == 'supplier_invoice') {
$payment_element = 'paiementfourn_facturefourn';
$fk_payment_element = 'fk_paiementfourn';
$fk_element = 'fk_facturefourn';
} else {
$langs->load('errors');
$this->errors[] = $langs->trans('ErrorBadParameters');
return -1;
}
// Get payment lines
$sql = "SELECT DISTINCT pe2.$fk_payment_element, pe2.$fk_element";
$sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element";
$sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_ids)) . ")";
dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->errors[] = "Error " . $this->db->lasterror();
return -1;
}
$current_payment_ids = array();
$payment_by_element = array();
$element_by_payment = array();
while ($obj = $this->db->fetch_object($resql)) {
$current_payment_ids[$obj->$fk_payment_element] = $obj->$fk_payment_element;
$element_by_payment[$obj->$fk_payment_element][$obj->$fk_element] = $obj->$fk_element;
$payment_by_element[$obj->$fk_element][$obj->$fk_payment_element] = $obj->$fk_payment_element;
}
$this->db->free($resql);
if (count(array_diff($payment_ids, $current_payment_ids))) {
return $this->getLinkedPaymentByGroup($current_payment_ids, $type);
}
return $this->getGroupElements($payment_by_element, $element_by_payment);
}
/**
* Get payment ids grouped by payment id and element id in common
*
* @param array $payment_by_element List of payment ids by element id
* @param array $element_by_payment List of element ids by payment id
* @param int $element_id Element Id (used for recursive function)
* @param array $current_group Current group (used for recursive function)
* @return array List of payment ids grouped by payment id and element id in common
*/
public function getGroupElements(&$payment_by_element, &$element_by_payment, $element_id = 0, &$current_group = array())
{
$grouped_payments = array();
if ($element_id > 0 && !isset($payment_by_element[$element_id])) {
// Return if specific element id not found
return $grouped_payments;
}
if ($element_id == 0) {
// Save list when is the begin of recursive function
$save_payment_by_element = $payment_by_element;
$save_element_by_payment = $element_by_payment;
}
do {
// Get current element id, get this payment id list and delete the entry
$current_element_id = $element_id > 0 ? $element_id : array_keys($payment_by_element)[0];
$payment_ids = $payment_by_element[$current_element_id];
unset($payment_by_element[$current_element_id]);
foreach ($payment_ids as $payment_id) {
// Continue if payment id in not found
if (!isset($element_by_payment[$payment_id])) continue;
// Set the payment in the current group
$current_group[$payment_id] = $payment_id;
// Get current element ids, get this payment id list and delete the entry
$element_ids = $element_by_payment[$payment_id];
unset($element_by_payment[$payment_id]);
// Set payment id on the current group for each element id of the payment
foreach ($element_ids as $id) {
$this->getGroupElements($payment_by_element, $element_by_payment, $id, $current_group);
}
}
if ($element_id == 0) {
// Save current group and reset the current group when is the begin of recursive function
$grouped_payments[] = $current_group;
$current_group = array();
}
} while (!empty($payment_by_element) && $element_id == 0);
if ($element_id == 0) {
// Restore list when is the begin of recursive function
$payment_by_element = $save_payment_by_element;
$element_by_payment = $save_element_by_payment;
}
return $grouped_payments;
}
}

View File

@ -68,7 +68,7 @@ $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$page = GETPOSTISSET('pageplusonPour le détail de la facture ref…e') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) {
$page = 0;
}
@ -137,9 +137,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco
if (!$error) {
$db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
$resql1 = $db->query($sql1);
@ -496,7 +496,7 @@ if ($result) {
}
print '</td>';
print '<td class="tdoverflowonsmartphone">';
print '<td class="tdoverflowonsmartphone small">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);

View File

@ -117,77 +117,79 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
print "<br>\n";
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
print "<br>\n"; print "<br>\n";
if (!empty($user->rights->accounting->chartofaccount)) {
print "<br>\n"; print "<br>\n";
print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
print '<hr>';
print "<br>\n";
print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
print '<hr>';
print "<br>\n";
// STEPS
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
print "<br>\n";
print $langs->trans("AccountancyAreaDescActionOnceBis");
print "<br>\n";
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
$s = str_replace('{s}', $textlink, $s);
print $s;
print "<br>\n";
if (!empty($conf->tax->enabled)) {
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
// STEPS
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
print "<br>\n";
print $langs->trans("AccountancyAreaDescActionOnceBis");
print "<br>\n";
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
$step++;
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
$s = str_replace('{s}', $textlink, $s);
print $s;
print "<br>\n";
}
if (!empty($conf->expensereport->enabled)) {
if (!empty($conf->tax->enabled)) {
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
$s = str_replace('{s}', $textlink, $s);
print $s;
print "<br>\n";
}
if (!empty($conf->expensereport->enabled)) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
print $s;
print "<br>\n";
}
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
print $s;
print "<br>\n";
print '<br>';
}
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
print $s;
print "<br>\n";
print '<br>';
// Step A - E
print "<br>\n";

View File

@ -117,7 +117,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.amount_main_currency, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
$sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
@ -142,7 +142,7 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid";
$sql .= " WHERE ba.fk_accountancy_journal=".((int) $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) {
$sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'";
}
@ -282,6 +282,7 @@ if ($result) {
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
$tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref;
$tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account;
$reg = array();
if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) {
$tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
} else {
@ -296,6 +297,12 @@ if ($result) {
$tabtype[$obj->rowid] = 'unknown';
$tabmoreinfo[$obj->rowid] = array();
$amounttouse = $obj->amount;
if (!empty($obj->amount_main_currency)) {
// If $obj->amount_main_currency is set, it means that $obj->amount is not in same currency, we must use $obj->amount_main_currency
$amounttouse = $obj->amount_main_currency;
}
// get_url may return -1 which is not traversable
if (is_array($links) && count($links) > 0) {
// Now loop on each link of record in bank (code similar to bankentries_list.php)
@ -334,7 +341,7 @@ if ($result) {
$societestatic->email = $tabcompany[$obj->rowid]['email'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
if ($compta_soc) {
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
$tabtp[$obj->rowid][$compta_soc] += $amounttouse;
}
} elseif ($links[$key]['type'] == 'user') {
$userstatic->id = $links[$key]['url_id'];
@ -350,7 +357,7 @@ if ($result) {
$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;
$tabtp[$obj->rowid][$compta_user] += $amounttouse;
}
} elseif ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
@ -383,7 +390,7 @@ if ($result) {
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
$tabtp[$obj->rowid][$objmid->accountancy_code] += $amounttouse;
}
} elseif ($links[$key]['type'] == 'payment_donation') {
$paymentdonstatic->id = $links[$key]['url_id'];
@ -391,7 +398,7 @@ if ($result) {
$paymentdonstatic->fk_donation = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
$tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
$tabtp[$obj->rowid][$account_pay_donation] += $amounttouse;
} elseif ($links[$key]['type'] == 'member') {
$paymentsubscriptionstatic->id = $links[$key]['url_id'];
$paymentsubscriptionstatic->ref = $links[$key]['url_id'];
@ -399,14 +406,14 @@ if ($result) {
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
$paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
$tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount;
$tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse;
} elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
$tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
$tabtp[$obj->rowid][$account_pay_vat] += $amounttouse;
} elseif ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
@ -438,7 +445,7 @@ if ($result) {
if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user.
$compta_user = $userstatic->accountancy_code;
if ($compta_user) {
$tabtp[$obj->rowid][$compta_user] += $obj->amount;
$tabtp[$obj->rowid][$compta_user] += $amounttouse;
$tabuser[$obj->rowid] = array(
'id' => $userstatic->id,
'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname),
@ -465,14 +472,14 @@ if ($result) {
$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
$tabpay[$obj->rowid]["account_various"] = $account_various;
$tabtp[$obj->rowid][$account_subledger] += $obj->amount;
$tabtp[$obj->rowid][$account_subledger] += $amounttouse;
} elseif ($links[$key]['type'] == 'payment_loan') {
$paymentloanstatic->id = $links[$key]['url_id'];
$paymentloanstatic->ref = $links[$key]['url_id'];
$paymentloanstatic->fk_loan = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id;
//$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount;
//$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse;
$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 .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid);
@ -488,14 +495,14 @@ if ($result) {
} elseif ($links[$key]['type'] == 'banktransfert') {
$accountLinestatic->fetch($links[$key]['url_id']);
$tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1);
$tabtp[$obj->rowid][$account_transfer] += $obj->amount;
$tabtp[$obj->rowid][$account_transfer] += $amounttouse;
$bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']);
$tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2);
}
}
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
$tabbq[$obj->rowid][$compta_bank] += $amounttouse;
// 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'.
@ -542,7 +549,7 @@ if ($result) {
}
}*/
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse;
$i++;
}
@ -658,6 +665,8 @@ if (!$error && $action == 'writebookkeeping') {
// Line into thirdparty account
foreach ($tabtp[$key] as $k => $mt) {
if ($mt) {
$lettering = false;
$reflabel = '';
if (!empty($val['lib'])) {
$reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : "");
@ -686,11 +695,13 @@ if (!$error && $action == 'writebookkeeping') {
$bookkeeping->date_creation = $now;
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
$lettering = true;
$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->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
$bookkeeping->label_compte = $accountingaccountcustomer->label;
} elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
$lettering = true;
$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->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
@ -773,6 +784,12 @@ if (!$error && $action == 'writebookkeeping') {
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} else {
if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
$lettering_static = new Lettering($db);
$nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id));
}
}
}
}

View File

@ -377,6 +377,12 @@ if ($action == 'writebookkeeping') {
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} else {
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
$lettering_static = new Lettering($db);
$nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'supplier_invoice');
}
}
}
}

View File

@ -390,6 +390,12 @@ if ($action == 'writebookkeeping') {
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} else {
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
$lettering_static = new Lettering($db);
$nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'customer_invoice');
}
}
}
}

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,6 +49,7 @@ $search_societe = GETPOST('search_societe', 'alpha');
$search_lineid = GETPOST('search_lineid', 'int');
$search_ref = GETPOST('search_ref', 'alpha');
$search_invoice = GETPOST('search_invoice', 'alpha');
$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
@ -112,6 +113,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_lineid = '';
$search_ref = '';
$search_invoice = '';
$search_ref_supplier = '';
$search_label = '';
$search_desc = '';
$search_amount = '';
@ -140,9 +142,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco
if (!$error) {
$db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
$resql1 = $db->query($sql1);
@ -236,6 +238,9 @@ if ($search_lineid) {
if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice);
}
if (strlen(trim($search_ref_supplier))) {
$sql .= natural_search("f.ref_supplier", $search_ref_supplier);
}
if (strlen(trim($search_label))) {
$sql .= natural_search("f.libelle", $search_label);
}
@ -328,6 +333,9 @@ if ($result) {
if ($search_ref) {
$param .= "&search_ref=".urlencode($search_ref);
}
if ($search_ref_supplier) {
$param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
}
if ($search_label) {
$param .= "&search_label=".urlencode($search_label);
}
@ -392,6 +400,7 @@ if ($result) {
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center">';
print '<div class="nowrap">';
@ -420,6 +429,7 @@ if ($result) {
print '<tr class="liste_titre">';
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("RefSupplier", $_SERVER["PHP_SELF"], "f.ref_supplier", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
@ -446,6 +456,9 @@ if ($result) {
$facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid;
$facturefournisseur_static->type = $objp->ftype;
$facturefournisseur_static->ref_supplier = $objp->ref_supplier;
$facturefournisseur_static->label = $objp->invoice_label;
$thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name;
@ -465,8 +478,8 @@ if ($result) {
$productstatic->status = $objp->tosell;
$productstatic->status_buy = $objp->tobuy;
$productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
$productstatic->accountancy_code_buy_intra = $objp->accountancy_code_sell_buy;
$productstatic->accountancy_code_buy_export = $objp->accountancy_code_sell_buy;
$productstatic->accountancy_code_buy_intra = $objp->accountancy_code_sell_buy_intra;
$productstatic->accountancy_code_buy_export = $objp->accountancy_code_sell_buy_export;
$accountingaccountstatic->rowid = $objp->fk_compte;
$accountingaccountstatic->label = $objp->label_account;
@ -481,7 +494,13 @@ if ($result) {
// Ref Invoice
print '<td class="nowraponall">'.$facturefournisseur_static->getNomUrl(1).'</td>';
print '<td class="tdoverflowonsmartphone">';
// Ref supplier invoice
print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($objp->ref_supplier).'">';
print $objp->ref_supplier;
print '</td>';
// Supplier invoice label
print '<td class="tdoverflowonsmartphone small" title="'.dol_escape_htmltag($objp->invoice_label).'">';
print $objp->invoice_label;
print '</td>';
@ -501,7 +520,7 @@ if ($result) {
}
print '</td>';
print '<td class="tdoverflowonsmartphone">';
print '<td class="tdoverflowonsmartphone small">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2021 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -55,6 +55,7 @@ $mesCasesCochees = GETPOST('toselect', 'array');
$search_societe = GETPOST('search_societe', 'alpha');
$search_lineid = GETPOST('search_lineid', 'int');
$search_ref = GETPOST('search_ref', 'alpha');
$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
$search_invoice = GETPOST('search_invoice', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
@ -137,6 +138,7 @@ if (empty($reshook)) {
$search_societe = '';
$search_lineid = '';
$search_ref = '';
$search_ref_supplier = '';
$search_invoice = '';
$search_label = '';
$search_desc = '';
@ -290,6 +292,9 @@ if (strlen(trim($search_invoice))) {
if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref);
}
if (strlen(trim($search_ref_supplier))) {
$sql .= natural_search("f.ref_supplier", $search_ref_supplier);
}
if (strlen(trim($search_label))) {
$sql .= natural_search(array("p.label", "f.libelle"), $search_label);
}
@ -413,6 +418,9 @@ if ($result) {
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_ref_supplier) {
$param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
@ -469,7 +477,8 @@ if ($result) {
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
@ -499,7 +508,8 @@ if ($result) {
print '<tr class="liste_titre">';
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
//print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("RefSupplier", $_SERVER["PHP_SELF"], "f.ref_supplier", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
//print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
@ -566,6 +576,7 @@ if ($result) {
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
$facturefourn_static->type = $objp->ftype;
$facturefourn_static->ref_supplier = $objp->ref_supplier;
$facturefourn_static->label = $objp->invoice_label;
$facturefourn_static->date = $db->jdate($objp->datef);
@ -625,15 +636,21 @@ if ($result) {
// Ref Invoice
print '<td class="nowraponall">'.$facturefourn_static->getNomUrl(1).'</td>';
/*print '<td class="tdoverflowonsmartphone">';
// Ref supplier invoice
print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($objp->ref_supplier).'">';
print $objp->ref_supplier;
print '</td>';
// Supplier invoice label
print '<td class="tdoverflowmax125 small" title="'.dol_escape_htmltag($objp->invoice_label).'">';
print $objp->invoice_label;
print '</td>';
*/
// Date
print '<td class="center">'.dol_print_date($facturefourn_static->date, 'day').'</td>';
// Ref Product
print '<td class="tdoverflowmax150">';
print '<td class="tdoverflowmax100">';
if ($product_static->id > 0) {
print $product_static->getNomUrl(1);
}

View File

@ -79,7 +79,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
}
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
}
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
@ -110,7 +110,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
$adherentstatic->firstname = $objp->firstname;
// Format extrafield so they can be parsed in function complete_substitutions_array
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$adherentstatic->array_options = array();
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$tmpkey = 'options_'.$key;

View File

@ -1534,9 +1534,9 @@ class Adherent extends CommonObject
*
* @param int $date Date of effect of subscription
* @param double $amount Amount of subscription (0 accepted for some members)
* @param int $accountid Id bank account
* @param string $operation Type of payment (if Id bank account provided). Example: 'CB', ...
* @param string $label Label operation (if Id bank account provided)
* @param int $accountid Id bank account. NOT USED.
* @param string $operation Code of payment mode (if Id bank account provided). Example: 'CB', ... NOT USED.
* @param string $label Label operation (if Id bank account provided).
* @param string $num_chq Numero cheque (if Id bank account provided)
* @param string $emetteur_nom Name of cheque writer
* @param string $emetteur_banque Name of bank of cheque

View File

@ -271,7 +271,7 @@ class AdherentType extends CommonObject
$result = $this->db->query($sql);
if ($result) {
// Call trigger
$result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user);
$result = $this->call_trigger('MEMBER_TYPE_DEL_MULTILANGS', $user);
if ($result < 0) {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);

View File

@ -177,8 +177,8 @@ if ($conf->use_javascript_ajax) {
$i = 0;
foreach ($AdherentType as $key => $adhtype) {
$dataval['draft'][] = array($i, isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0);
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0);
$dataval['uptodate'][] = array($i, isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0);
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0);
$dataval['excluded'][] = array($i, isset($MembersExcluded[$key]) ? $MembersExcluded[$key] : 0);
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
@ -191,18 +191,18 @@ if ($conf->use_javascript_ajax) {
}
$total = $SumToValidate + $SumValidated + $SumUpToDate + $SumExcluded + $SumResiliated;
$dataseries = array();
$dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumValidated));
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate)); // Draft, not yet validated
$dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SumUpToDate));
$dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumValidated));
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), round($SumExcluded));
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SumResiliated));
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate));
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, '-'.$badgeStatus8, $badgeStatus6, '-'.$badgeStatus0));
$dolgraph->SetDataColor(array('-'.$badgeStatus0, $badgeStatus4, '-'.$badgeStatus1, '-'.$badgeStatus8, $badgeStatus6));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));

View File

@ -172,7 +172,7 @@ $result = restrictedArea($user, 'adherent');
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
@ -215,7 +215,7 @@ if (empty($reshook)) {
$search_status = "";
$catid = "";
$sall = "";
$toselect = '';
$toselect = array();
$search_array_options = array();
}
@ -482,7 +482,7 @@ if (GETPOSTISSET("search_status")) {
$titre = $langs->trans("MembersListToValid");
}
if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') {
$titre = $langs->trans("MembersValidated");
$titre = $langs->trans("MenuMembersValidated");
}
if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') {
$titre = $langs->trans("MembersWithSubscriptionToReceive");
@ -505,7 +505,7 @@ if (GETPOSTISSET("search_status")) {
if ($search_type > 0) {
$membertype = new AdherentType($db);
$result = $membertype->fetch(GETPOST("type", 'int'));
$result = $membertype->fetch($search_type);
$titre .= " (".$membertype->label.")";
}
@ -587,7 +587,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').'&ensp;'.$langs->trans("SendByMail"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
);
if ($user->rights->adherent->creer) {
@ -767,7 +767,7 @@ if (!empty($arrayfields['d.email']['checked'])) {
}
// End of subscription date
if (!empty($arrayfields['d.datefin']['checked'])) {
print '<td class="liste_titre left">';
print '<td class="liste_titre center">';
$selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
print $form->selectarray('search_filter', $selectarray, $search_filter);
print '</td>';
@ -858,7 +858,7 @@ if (!empty($arrayfields['state.nom']['checked'])) {
print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['country.code_iso']['checked'])) {
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['d.phone']['checked'])) {
print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
@ -873,7 +873,7 @@ if (!empty($arrayfields['d.email']['checked'])) {
print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.datefin']['checked'])) {
print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, '', $sortfield, $sortorder, 'center ');
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -1110,16 +1110,14 @@ while ($i < min($num, $limit)) {
// End of subscription date
$datefin = $db->jdate($obj->datefin);
if (!empty($arrayfields['d.datefin']['checked'])) {
print '<td class="nowrap center">';
if ($datefin) {
print '<td class="nowrap center">';
print dol_print_date($datefin, 'day');
if ($memberstatic->hasDelay()) {
$textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')';
print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
}
print '</td>';
} else {
print '<td class="nowrap left">';
if (!empty($obj->subscription)) {
print $langs->trans("SubscriptionNotReceived");
if ($obj->statut > 0) {
@ -1128,8 +1126,8 @@ while ($i < min($num, $limit)) {
} else {
print '&nbsp;';
}
print '</td>';
}
print '</td>';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';

View File

@ -111,7 +111,7 @@ $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
@ -135,7 +135,7 @@ if (empty($reshook)) {
$search_note = "";
$search_amount = "";
$search_account = "";
$toselect = '';
$toselect = array();
$search_array_options = array();
}
}

View File

@ -125,6 +125,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
$object->note = trim($comment);
$object->note_public = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->vote = (int) $vote;
@ -176,6 +177,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
$object->note = trim($comment);
$object->note_public = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote);
@ -358,7 +360,7 @@ if ($action == 'create') {
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
print '</td></tr>';
// Morphy
@ -375,7 +377,7 @@ if ($action == 'create') {
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>';
print '<input name="amount" size="5" value="'.price($amount).'">';
print '<input name="amount" size="5" value="'.(GETPOSTISSET('amount') ? GETPOST('amount') : price($amount)).'">';
print '</td></tr>';
print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
@ -389,12 +391,12 @@ if ($action == 'create') {
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
$doleditor = new DolEditor('comment', (GETPOSTISSET('comment') ? GETPOST('comment', 'restricthtml') : $object->note_public), '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
$doleditor = new DolEditor('mail_valid', GETPOSTISSET('mail_valid') ? GETPOST('mail_valid') : $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print '</td></tr>';
@ -783,7 +785,7 @@ if ($rowid > 0) {
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth300" name="label" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
print '</td></tr>';
// Morphy

View File

@ -302,6 +302,7 @@ foreach ($dirmodels as $reldir) {
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$commande->type = 0;
$nextval = $module->getNextValue($mysoc, $commande);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': ';
@ -614,7 +615,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
$doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td><td class="right">';
@ -630,7 +631,7 @@ print "<input type=\"hidden\" name=\"action\" value=\"set_COMMANDE_DRAFT_WATERMA
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
print '</td><td>';
print '<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.$conf->global->COMMANDE_DRAFT_WATERMARK.'">';
print '<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.getDolGlobalString('COMMANDE_DRAFT_WATERMARK').'">';
print '</td><td class="right">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";

View File

@ -369,7 +369,7 @@ $form = new Form($db);
$formother = new FormOther($db);
$formcompany = new FormCompany($db);
$countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</span>';
$countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' <a href="#trzipbeforecountry">('.$langs->trans("SeeAbove").')</a></span>';
print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
@ -410,10 +410,10 @@ print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'.(GETPOSTISSET('MAIN_INFO_SOCIETE_ADDRESS') ? GETPOST('MAIN_INFO_SOCIETE_ADDRESS', 'nohtml') : (!empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS) ? $conf->global->MAIN_INFO_SOCIETE_ADDRESS : '')).'</textarea></td></tr>'."\n";
// Zip
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<tr class="oddeven" id="trzipbeforecountry"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="width100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_INFO_SOCIETE_ZIP') ? GETPOST('MAIN_INFO_SOCIETE_ZIP', 'alpha') : (!empty($conf->global->MAIN_INFO_SOCIETE_ZIP) ? $conf->global->MAIN_INFO_SOCIETE_ZIP : ''))).'"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<tr class="oddeven" id="trtownbeforecountry"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_INFO_SOCIETE_TOWN') ? GETPOST('MAIN_INFO_SOCIETE_TOWN', 'nohtml') : (!empty($conf->global->MAIN_INFO_SOCIETE_TOWN) ? $conf->global->MAIN_INFO_SOCIETE_TOWN : ''))).'"></td></tr>'."\n";
// Country

View File

@ -93,15 +93,17 @@ print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td
print '<td class="right"><input type="submit" class="button button-edit" '.$option.' value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';
print '<td colspan="2"><input type="text" class="flat" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">'; // This slow seriously output
print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput");
print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("DEBUGBAR_USE_LOG_FILE").'</td>';
print '<td>';
print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
print '</td><td>';
print '<span class="opacitymedium"> '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").'</span>';
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_USE_LOG_FILE").'</td>';
print '<td colspan="2">';
print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower");
print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';
print '<td><input type="text" class="flat width75" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">'; // This slow seriously output
print '</td><td>';
print '<span class="opacitymedium">'.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").'</span>';
print '</td></tr>';
print '</table>';

View File

@ -101,7 +101,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$defaulturl = '';
$defaultkey = '';
$defaultvalue = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2017 Oscss-Shop <support@oscss-shop.fr>.
* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modifyion 2.0 (the "License");
* it under the terms of the GNU General Public License as published bypliance with the License.
@ -17,9 +17,6 @@
* or see https://www.gnu.org/
*/
if (!defined('REQUIRE_JQUERY_BLOCKUI')) {
define('REQUIRE_JQUERY_BLOCKUI', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}

View File

@ -232,6 +232,9 @@ class PrestaShopWebservice
if ($response != '') {
libxml_clear_errors();
libxml_use_internal_errors(true);
if (!function_exists('simplexml_load_string')) {
throw new PrestaShopWebserviceException('Method simplexml_load_string not available. Your PHP does not support xml.');
}
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
if (libxml_get_errors()) {
$msg = var_export(libxml_get_errors(), true);

View File

@ -67,9 +67,6 @@ div.divsearchfield {
.tree li:last-child:after{
display: none
}
.blockUI {
cursor: auto!important;
}
.newAppParent{
position: relative;
overflow: hidden;

View File

@ -428,15 +428,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
}
$timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
$timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
$timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
$timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 20 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
dol_syslog("imap_open connectstring=".$connectstringsource." login=".$object->login." password=".$object->password." timeoutconnect=".$timeoutconnect." timeoutread=".$timeoutread);
imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect);
imap_timeout(IMAP_READTIMEOUT, $timeoutread);
$result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect); // timeout seems ignored with ssl connect
$result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
$result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
$result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
dol_syslog("result1=".$result1." result2=".$result2." result3=".$result3." result4=".$result4);
$connection = imap_open($connectstringsource, $object->login, $object->password);
//dol_syslog("end imap_open connection=".var_export($connection, true));
} catch (Exception $e) {
print $e->getMessage();
}
@ -490,7 +496,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelineoffilters" class="noborder margintable noshadow">';
print '<tr class="liste_titre nodrag nodrop">';
print '<td>'.img_picto('', 'filter', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
print '<td>'.img_picto('', 'filter', 'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
print '</tr>';
// Add filter
print '<tr class="oddeven nodrag nodrop">';
@ -647,7 +653,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
}
print '</td>';
print '<td class="wordbreak minwidth300">';
print '<td class="wordbreak minwidth300 small">';
if ($action == 'editoperation' && $ruleaction['id'] == $operationid) {
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'">';

View File

@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
dol_include_once('/emailcollector/class/emailcollector.class.php');
// Load translation files required by page
@ -43,6 +44,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$mode = GETPOST('mode', 'aZ');
$id = GETPOST('id', 'int');
@ -52,8 +54,9 @@ $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
// If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
}
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -73,7 +76,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
$sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
@ -88,12 +91,16 @@ if ($user->socid > 0) { // Protection if external user
//$result = restrictedArea($user, 'emailcollector', $id, '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alphanohtml');
$search_all = GETPOST('search_all', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
}
}
// List of fields to search into when doing a "search in all"
@ -109,29 +116,19 @@ $arrayfields = array();
foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = dol_eval($val['visible'], 1, 1, '1');
$visible = (int) dol_eval($val['visible'], 1);
$arrayfields['t.'.$key] = array(
'label'=>$val['label'],
'checked'=>(($visible < 0) ? 0 : 1),
'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
'position'=>$val['position']
'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
'position'=>$val['position'],
'help'=> isset($val['help']) ? $val['help'] : ''
);
}
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]),
'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key]
);
}
}
}
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
@ -156,7 +153,8 @@ if (empty($conf->emailcollector->enabled)) {
*/
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
$action = 'list';
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
@ -176,8 +174,12 @@ if (empty($reshook)) {
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
foreach ($object->fields as $key => $val) {
$search[$key] = '';
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = '';
$search[$key.'_dtend'] = '';
}
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
@ -200,20 +202,22 @@ if (empty($reshook)) {
$form = new Form($db);
$now = dol_now();
$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector"));
$morejs = array();
$morecss = array();
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach ($object->fields as $key => $val) {
$sql .= "t.".$key.", ";
}
$sql .= $object->getFieldList('t');
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
}
}
// Add fields from hooks
@ -222,7 +226,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
if ($object->ismultientitymanaged == 1) {
@ -231,18 +235,32 @@ if ($object->ismultientitymanaged == 1) {
$sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') {
$search[$key] = '';
if (array_key_exists($key, $object->fields)) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
$search[$key] = '';
}
$mode_search = 2;
}
if ($search[$key] != '') {
$sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
}
} else {
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
$columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
if (preg_match('/_dtstart$/', $key)) {
$sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
}
if (preg_match('/_dtend$/', $key)) {
$sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
}
}
}
$mode_search = 2;
}
if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
@ -257,49 +275,48 @@ $sql .= $hookmanager->resPrint;
/* If a group by is required
$sql.= " GROUP BY ";
foreach ($object->fields as $key => $val)
{
$sql .= "t.".$key.", ";
foreach ($object->fields as $key => $val) {
$sql .= "t.".$db->escape($key).", ";
}
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
}
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql);
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
*/
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
$db->free($resql);
}
// Complete request and execute it with limit
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
@ -313,7 +330,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
$arrayofselected = is_array($toselect) ? $toselect : array();
@ -327,9 +344,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
if ($skey != '') {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
}
} else {
} elseif ($search[$key] != '') {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
@ -338,6 +357,10 @@ if ($optioncss != '') {
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(
@ -352,7 +375,7 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
@ -407,25 +430,43 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print '</td>';
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
} elseif ($key == 'lang') {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($db);
print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
} else {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
print '</td>';
}
@ -438,45 +479,57 @@ $parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print '</tr>'."\n";
$totalarray = array();
$totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
$cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
$totalarray['nbfield']++;
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
$totalarray['nbfield']++;
print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
@ -488,8 +541,10 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num)) {
$savnbfield = $totalarray['nbfield'];
$totalarray['nbfield'] = 0;
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
@ -498,73 +553,107 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
// Show here line of result
print '<tr class="oddeven">';
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
if ($mode == 'kanban') {
if ($i == 0) {
print '<tr><td colspan="'.$savnbfield.'">';
print '<div class="box-flex-container">';
}
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
// Output Kanban
print $object->getKanbanView('');
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') {
print $object->getLibStatut(5);
} else {
print $object->showOutputField($val, $key, $object->$key, '');
} else {
// Show here line of result
$j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
print '</tr>'."\n";
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '');
if (preg_match('/tdoverflow/', $cssforfield)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
}
print '>';
if ($key == 'status') {
print $object->getLibStatut(5);
} elseif ($key == 'rowid') {
print $object->showOutputField($val, $key, $object->id, '');
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
}
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
}
$i++;
}
@ -581,7 +670,7 @@ if ($num == 0) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
@ -594,6 +683,34 @@ print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print load_fiche_titre($langs->trans("Other"), '', '');
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td></td>';
print "</tr>\n";
// Hide e-mail headers from collected messages
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).'</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
}
print '</td>';
print '</tr>';
print '</table>';
print '</div>';
print '<br>';
print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {

View File

@ -222,6 +222,7 @@ if ($action == 'edit') {
$setupnotempty++;
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
$tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
print '</td><td>';
@ -314,6 +315,7 @@ if ($action == 'edit') {
$setupnotempty++;
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
$tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
print '</td><td>';
@ -455,7 +457,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -595,7 +597,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -38,169 +38,178 @@ if (!$user->admin) {
accessforbidden();
}
//Init error
$error = false;
$message = false;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admin', 'dictionaryadmin','expensereport_rules'));
$action = GETPOST('action', 'aZ09');
$id = GETPOST('id', 'int');
$apply_to = GETPOST('apply_to');
$fk_user = GETPOST('fk_user', 'int');
$fk_usergroup = GETPOST('fk_usergroup', 'int');
$fk_c_type_fees = GETPOST('fk_c_type_fees');
$code_expense_rules_type = GETPOST('code_expense_rules_type');
$dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$amount = GETPOST('amount');
$object = new ExpenseReportRule($db);
if (!empty($id)) {
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error('', $object->error, $object->errors);
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
// TODO do action
if ($action == 'save') {
$error = 0;
if (empty($reshook)) {
//Init error
$error = false;
$message = false;
// check parameters
if (empty($apply_to)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportApplyTo")), null, 'errors');
}
if (empty($fk_c_type_fees)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportDomain")), null, 'errors');
}
if (empty($code_expense_rules_type)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportLimitOn")), null, 'errors');
}
if (empty($dates)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportDateStart")), null, 'errors');
}
if (empty($datee)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportDateEnd")), null, 'errors');
}
if (empty($amount)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportLimitAmount")), null, 'errors');
}
$action = GETPOST('action', 'aZ09');
$id = GETPOST('id', 'int');
if (empty($error)) {
$object->setValues($_POST);
$apply_to = GETPOST('apply_to');
$fk_user = GETPOST('fk_user', 'int');
$fk_usergroup = GETPOST('fk_usergroup', 'int');
if ($apply_to == 'U') {
$object->fk_user = (int) $fk_user;
$object->fk_usergroup = 0;
$object->is_for_all = 0;
} elseif ($apply_to == 'G') {
$object->fk_usergroup = (int) $fk_usergroup;
$object->fk_user = 0;
$object->is_for_all = 0;
} elseif ($apply_to == 'A') {
$object->is_for_all = 1;
$object->fk_user = 0;
$object->fk_usergroup = 0;
$fk_c_type_fees = GETPOST('fk_c_type_fees');
$code_expense_rules_type = GETPOST('code_expense_rules_type');
$dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$amount = GETPOST('amount');
$object = new ExpenseReportRule($db);
if (!empty($id)) {
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error('', $object->error, $object->errors);
}
}
// TODO do action
if ($action == 'save') {
$error = 0;
// check parameters
if (empty($apply_to)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportApplyTo")), null, 'errors');
}
if (empty($fk_c_type_fees)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportDomain")), null, 'errors');
}
if (empty($code_expense_rules_type)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportLimitOn")), null, 'errors');
}
if (empty($dates)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportDateStart")), null, 'errors');
}
if (empty($datee)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportDateEnd")), null, 'errors');
}
if (empty($amount)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportLimitAmount")), null, 'errors');
}
$object->dates = $dates;
$object->datee = $datee;
if (empty($error)) {
$object->setValues($_POST);
$object->entity = $conf->entity;
if ($apply_to == 'U') {
$object->fk_user = (int) $fk_user;
$object->fk_usergroup = 0;
$object->is_for_all = 0;
} elseif ($apply_to == 'G') {
$object->fk_usergroup = (int) $fk_usergroup;
$object->fk_user = 0;
$object->is_for_all = 0;
} elseif ($apply_to == 'A') {
$object->is_for_all = 1;
$object->fk_user = 0;
$object->fk_usergroup = 0;
}
$res = $object->create($user);
if ($res > 0) {
setEventMessages($langs->trans('ExpenseReportRuleSave'), null);
} else {
$object->dates = $dates;
$object->datee = $datee;
$object->entity = $conf->entity;
$res = $object->create($user);
if ($res > 0) {
setEventMessages($langs->trans('ExpenseReportRuleSave'), null);
} else {
dol_print_error($object->db);
}
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
} elseif ($action == 'delete') {
// TODO add confirm
$res = $object->delete($user);
if ($res < 0) {
dol_print_error($object->db);
}
header('Location: '.$_SERVER['PHP_SELF']);
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
} elseif ($action == 'delete') {
// TODO add confirm
$res = $object->delete($user);
if ($res < 0) {
dol_print_error($object->db);
}
$rules = $object->getAllRule();
header('Location: '.$_SERVER['PHP_SELF']);
exit;
$tab_apply = array(
'A' => $langs->trans('All'),
'G' => $langs->trans('Group'),
'U' => $langs->trans('User')
);
$tab_rules_type = array(
'EX_DAY' => $langs->trans('Day'),
'EX_MON' => $langs->trans('Month'),
'EX_YEA' => $langs->trans('Year'),
'EX_EXP' => $langs->trans('OnExpense')
);
}
/*
* View
*/
$rules = $object->getAllRule();
llxHeader('', $langs->trans("ExpenseReportsSetup"));
$tab_apply = array(
'A' => $langs->trans('All'),
'G' => $langs->trans('Group'),
'U' => $langs->trans('User')
);
$tab_rules_type = array(
'EX_DAY' => $langs->trans('Day'),
'EX_MON' => $langs->trans('Month'),
'EX_YEA' => $langs->trans('Year'),
'EX_EXP' => $langs->trans('OnExpense')
);
$form = new Form($db);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
/*
* View
*/
$head = expensereport_admin_prepare_head();
print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
llxHeader('', $langs->trans("ExpenseReportsSetup"));
$form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
$head = expensereport_admin_prepare_head();
print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportRulesDesc').'</span>';
print '<br><br>';
echo '<span class="opacitymedium">' . $langs->trans('ExpenseReportRulesDesc') . '</span>';
print '<br><br>';
if ($action != 'edit') {
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '<input type="hidden" name="token" value="'.newToken().'" />';
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
echo '<input type="hidden" name="token" value="' . newToken() . '" />';
echo '<input type="hidden" name="action" value="save" />';
echo '<table class="noborder centpercent">';
echo '<tr class="liste_titre">';
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
echo '<th>'.$langs->trans('Type').'</th>';
echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>';
echo '<th>'.$langs->trans('ExpenseReportLimitAmount').'</th>';
echo '<th>'.$langs->trans('ExpenseReportRestrictive').'</th>';
echo '<tr class="liste_titre headerexpensereportrules">';
echo '<th class="linecolapplyto">' . $langs->trans('ExpenseReportApplyTo') . '</th>';
echo '<th class="linecoltype">' . $langs->trans('Type') . '</th>';
echo '<th class="linecollimiton">' . $langs->trans('ExpenseReportLimitOn') . '</th>';
echo '<th class="linecoldatestart">' . $langs->trans('ExpenseReportDateStart') . '</th>';
echo '<th class="linecoldateend">' . $langs->trans('ExpenseReportDateEnd') . '</th>';
echo '<th class="linecollimitamount">' . $langs->trans('ExpenseReportLimitAmount') . '</th>';
echo '<th class="linecolrestrictive">' . $langs->trans('ExpenseReportRestrictive') . '</th>';
echo '<th>&nbsp;</th>';
echo '</tr>';
echo '<tr class="oddeven">';
echo '<td>';
echo '<div class="float">'.$form->selectarray('apply_to', $tab_apply, '', 0).'</div>';
echo '<div id="user" class="float">'.$form->select_dolusers('', 'fk_user').'</div>';
echo '<div id="group" class="float">'.$form->select_dolgroups('', 'fk_usergroup').'</div>';
echo '<div class="float linecolapplyto">' . $form->selectarray('apply_to', $tab_apply, '', 0) . '</div>';
echo '<div id="user" class="float linecoluser">' . $form->select_dolusers('', 'fk_user') . '</div>';
echo '<div id="group" class="float linecolgroup">' . $form->select_dolgroups('', 'fk_usergroup') . '</div>';
echo '</td>';
echo '<td>'.$form->selectExpense('', 'fk_c_type_fees', 0, 1, 1).'</td>';
echo '<td>'.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).'</td>';
echo '<td>'.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).'</td>';
echo '<td>'.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).'</td>';
echo '<td><input type="text" value="" class="maxwidth100" name="amount" class="amount" /> '.$conf->currency.'</td>';
echo '<td>'.$form->selectyesno('restrictive', 0, 1).'</td>';
echo '<td class="right"><input type="submit" class="button button-add" value="'.$langs->trans('Add').'" /></td>';
echo '<td class="linecoltype">' . $form->selectExpense('', 'fk_c_type_fees', 0, 1, 1) . '</td>';
echo '<td class="linecoltyperule">' . $form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0) . '</td>';
echo '<td class="linecoldatestart">' . $form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0) . '</td>';
echo '<td class="linecoldateend>' . $form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0) . '</td>';
echo '<td class="linecolamount"><input type="text" value="" class="maxwidth100" name="amount" class="amount" /> ' . $conf->currency . '</td>';
echo '<td class="linecolrestrictive">' . $form->selectyesno('restrictive', 0, 1) . '</td>';
echo '<td class="right linecolbutton"><input type="submit" class="button button-add" value="' . $langs->trans('Add') . '" /></td>';
echo '</tr>';
echo '</table>';
@ -208,60 +217,60 @@ if ($action != 'edit') {
}
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '<input type="hidden" name="token" value="'.newToken().'" />';
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
echo '<input type="hidden" name="token" value="' . newToken() . '" />';
if ($action == 'edit') {
echo '<input type="hidden" name="id" value="'.$object->id.'" />';
echo '<input type="hidden" name="id" value="' . $object->id . '" />';
echo '<input type="hidden" name="action" value="save" />';
}
echo '<table class="noborder centpercent">';
echo '<table class="noborder centpercent">';
echo '<tr class="liste_titre">';
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
echo '<th>'.$langs->trans('Type').'</th>';
echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>';
echo '<th>'.$langs->trans('ExpenseReportLimitAmount').'</th>';
echo '<th>'.$langs->trans('ExpenseReportRestrictive').'</th>';
echo '<th>&nbsp;</th>';
echo '</tr>';
echo '<tr class="liste_titre expensereportrules">';
echo '<th class="linecolapplyto">' . $langs->trans('ExpenseReportApplyTo') . '</th>';
echo '<th class="linecoltype">' . $langs->trans('Type') . '</th>';
echo '<th class="linecollimiton">' . $langs->trans('ExpenseReportLimitOn') . '</th>';
echo '<th class="linecoldatestart">' . $langs->trans('ExpenseReportDateStart') . '</th>';
echo '<th class="linecoldateend">' . $langs->trans('ExpenseReportDateEnd') . '</th>';
echo '<th class="linecollimitamount">' . $langs->trans('ExpenseReportLimitAmount') . '</th>';
echo '<th class="linecolrestrictive">' . $langs->trans('ExpenseReportRestrictive') . '</th>';
echo '<th>&nbsp;</th>';
echo '</tr>';
foreach ($rules as $rule) {
echo '<tr class="oddeven">';
echo '<tr class="oddeven linetrdata" id="'.$rule->id.'">';
echo '<td>';
echo '<td class="linecolusergroup">';
if ($action == 'edit' && $object->id == $rule->id) {
$selected = ($object->is_for_all > 0) ? 'A' : ($object->fk_usergroup > 0 ? 'G' : 'U');
echo '<div class="float">'.$form->selectarray('apply_to', $tab_apply, $selected, 0).'</div>';
echo '<div id="user" class="float">'.$form->select_dolusers($object->fk_user, 'fk_user').'</div>';
echo '<div id="group" class="float">'.$form->select_dolgroups($object->fk_usergroup, 'fk_usergroup').'</div>';
echo '<div class="float">' . $form->selectarray('apply_to', $tab_apply, $selected, 0) . '</div>';
echo '<div id="user" class="float">' . $form->select_dolusers($object->fk_user, 'fk_user') . '</div>';
echo '<div id="group" class="float">' . $form->select_dolgroups($object->fk_usergroup, 'fk_usergroup') . '</div>';
} else {
if ($rule->is_for_all > 0) {
echo $tab_apply['A'];
} elseif ($rule->fk_usergroup > 0) {
echo $tab_apply['G'].' ('.$rule->getGroupLabel().')';
echo $tab_apply['G'] . ' (' . $rule->getGroupLabel() . ')';
} elseif ($rule->fk_user > 0) {
echo $tab_apply['U'].' ('.$rule->getUserName().')';
echo $tab_apply['U'] . ' (' . $rule->getUserName() . ')';
}
}
echo '</td>';
echo '<td>';
echo '<td class="linecoltype">';
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1);
} else {
if ($rule->fk_c_type_fees == -1) {
echo $langs->trans('AllExpenseReport');
} else {
$key = getDictionaryValue(MAIN_DB_PREFIX.'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id');
$key = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id');
if ($key && $key != $langs->trans($key)) {
echo $langs->trans($key);
} else {
$value = getDictionaryValue(MAIN_DB_PREFIX.'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id');
$value = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id');
echo $langs->trans($value ? $value : 'Undefined'); // TODO check to return trans of 'code'
}
}
@ -269,7 +278,7 @@ foreach ($rules as $rule) {
echo '</td>';
echo '<td>';
echo '<td class="linecoltyperule">';
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectarray('code_expense_rules_type', $tab_rules_type, $object->code_expense_rules_type, 0);
} else {
@ -278,7 +287,7 @@ foreach ($rules as $rule) {
echo '</td>';
echo '<td>';
echo '<td class="linecoldatestart">';
if ($action == 'edit' && $object->id == $rule->id) {
print $form->selectDate(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0);
} else {
@ -287,7 +296,7 @@ foreach ($rules as $rule) {
echo '</td>';
echo '<td>';
echo '<td class="linecoldateend">';
if ($action == 'edit' && $object->id == $rule->id) {
print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0);
} else {
@ -296,16 +305,16 @@ foreach ($rules as $rule) {
echo '</td>';
echo '<td>';
echo '<td class="linecolamount">';
if ($action == 'edit' && $object->id == $rule->id) {
echo '<input type="text" value="'.price2num($object->amount).'" name="amount" class="amount" />'.$conf->currency;
echo '<input type="text" value="' . price2num($object->amount) . '" name="amount" class="amount" />' . $conf->currency;
} else {
echo price($rule->amount, 0, $langs, 1, -1, -1, $conf->currency);
}
echo '</td>';
echo '<td>';
echo '<td class="linecolrestrictive">';
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectyesno('restrictive', $object->restrictive, 1);
} else {
@ -316,11 +325,11 @@ foreach ($rules as $rule) {
echo '<td class="center">';
if ($object->id != $rule->id) {
echo '<a class="editfielda paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$rule->id.'">'.img_edit().'</a>&nbsp;';
echo '<a class="paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$rule->id.'">'.img_delete().'</a>';
echo '<a class="editfielda paddingright paddingleft" href="' . $_SERVER['PHP_SELF'] . '?action=edit&token=' . newToken() . '&id=' . $rule->id . '">' . img_edit() . '</a>&nbsp;';
echo '<a class="paddingright paddingleft" href="' . $_SERVER['PHP_SELF'] . '?action=delete&token=' . newToken() . '&id=' . $rule->id . '">' . img_delete() . '</a>';
} else {
echo '<input type="submit" class="button button-edit" value="'.$langs->trans('Update').'" />&nbsp;';
echo '<a href="'.$_SERVER['PHP_SELF'].'" class="button button-cancel">'.$langs->trans("Cancel").'</a>';
echo '<input type="submit" class="button button-edit" value="' . $langs->trans('Update') . '" />&nbsp;';
echo '<a href="' . $_SERVER['PHP_SELF'] . '" class="button button-cancel">' . $langs->trans("Cancel") . '</a>';
}
echo '</td>';
@ -328,10 +337,10 @@ foreach ($rules as $rule) {
}
echo '</table>';
echo '</form>';
echo '</table>';
echo '</form>';
echo '<script type="text/javascript"> $(function() {
echo '<script type="text/javascript"> $(function() {
$("#apply_to").change(function() {
var value = $(this).val();
if (value == "A") {
@ -349,6 +358,7 @@ echo '<script type="text/javascript"> $(function() {
}); </script>';
print dol_get_fiche_end();
// End of page

View File

@ -225,6 +225,12 @@ if ($action == 'updateMask') {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
} elseif ($action == 'set_INVOICE_CHECK_POSTERIOR_DATE') {
$check_posterior_date = GETPOST('INVOICE_CHECK_POSTERIOR_DATE', 'int');
$res = dolibarr_set_const($db, 'INVOICE_CHECK_POSTERIOR_DATE', $check_posterior_date, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
@ -761,6 +767,25 @@ print '<input type="submit" class="button button-edit" value="'.$langs->trans("M
print "</td></tr>\n";
print '</form>';
print '<tr class="oddeven"><td>'.$langs->trans("InvoiceCheckPosteriorDate"). '&nbsp;' ;
print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
} else {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="action" value="set_INVOICE_CHECK_POSTERIOR_DATE" />';
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("INVOICE_CHECK_POSTERIOR_DATE", $arrval, $conf->global->INVOICE_CHECK_POSTERIOR_DATE);
print '</td>';
print '<td class="center">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'" />';
print '</form>';
}
print '</td></tr>';
print '</table>';
print '</div>';

View File

@ -110,7 +110,8 @@ if (GETPOST('save', 'alpha')) {
$fckeditor_skin = GETPOST('fckeditor_skin', 'alpha');
if (!empty($fckeditor_skin)) {
if (!dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity)) {
$result = dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
$error++;
}
} else {
@ -119,7 +120,8 @@ if (GETPOST('save', 'alpha')) {
$fckeditor_test = GETPOST('formtestfield', 'restricthtml');
if (!empty($fckeditor_test)) {
if (!dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) {
$result = dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
$error++;
}
} else {
@ -129,7 +131,7 @@ if (GETPOST('save', 'alpha')) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
setEventMessages($langs->trans("Error").' '.$db->lasterror(), null, 'errors');
}
}

View File

@ -279,7 +279,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -421,7 +421,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -475,6 +475,7 @@ if ($mode == 'other') {
print '<div class="center">';
print '<input class="button button-save reposition" type="submit" name="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button button-cancel reposition" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '<br>';
@ -485,18 +486,17 @@ if ($mode == 'other') {
print '<table summary="otherparameters" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">';
print $langs->trans("Miscelaneous");
print '</td><td class="titlefieldmiddle">';
print '</td></tr>';
print $langs->trans("Miscellaneous");
print '</td>';
print '<td class="titlefieldmiddle"></td>';
print '</tr>';
// Max size of lists
print '<tr class="oddeven"><td>' . $langs->trans("DefaultMaxSizeList") . '</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Max size of short lists on customer card
print '<tr class="oddeven"><td>' . $langs->trans("DefaultMaxSizeShortList") . '</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// show input border
@ -504,7 +504,6 @@ if ($mode == 'other') {
print '<tr><td>'.$langs->trans("showInputBorder").'</td><td>';
print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
*/
@ -512,21 +511,18 @@ if ($mode == 'other') {
print '<tr class="oddeven"><td>' . $langs->trans("WeekStartOnDay") . '</td><td>';
print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// DefaultWorkingDays
print '<tr class="oddeven"><td>' . $langs->trans("DefaultWorkingDays") . '</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="' . (isset($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? $conf->global->MAIN_DEFAULT_WORKING_DAYS : '1-5') . '">';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// DefaultWorkingHours
print '<tr class="oddeven"><td>' . $langs->trans("DefaultWorkingHours") . '</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="' . (isset($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? $conf->global->MAIN_DEFAULT_WORKING_HOURS : '9-18') . '">';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Firstname/Name
@ -534,7 +530,6 @@ if ($mode == 'other') {
$array = array(0 => $langs->trans("Firstname") . ' ' . $langs->trans("Lastname"), 1 => $langs->trans("Lastname") . ' ' . $langs->trans("Firstname"));
print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0));
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Hide unauthorized menus
@ -542,7 +537,6 @@ if ($mode == 'other') {
//print $form->selectyesno('MAIN_MENU_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_MENU_HIDE_UNAUTHORIZED : 0, 1);
print ajax_constantonoff("MAIN_MENU_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other');
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Hide unauthorized button
@ -550,7 +544,6 @@ if ($mode == 'other') {
//print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1);
print ajax_constantonoff("MAIN_BUTTON_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other');
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Hide version link
@ -559,17 +552,21 @@ if ($mode == 'other') {
print '<tr><td>'.$langs->trans("HideVersionLink").'</td><td>';
print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
*/
// Show Quick Add link
print '<tr class="oddeven"><td>' . $langs->trans("ShowQuickAddLink") . '</td><td>';
print ajax_constantonoff("MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other');
print '</td>';
print '</tr>';
// Show bugtrack link
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")), $langs->trans("ShowBugTrackLinkDesc"));
print '</td><td>';
print '<input type="text" name="MAIN_BUGTRACK_ENABLELINK" value="' . (empty($conf->global->MAIN_BUGTRACK_ENABLELINK) ? '' : $conf->global->MAIN_BUGTRACK_ENABLELINK) . '">';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Hide wiki link on login page
@ -578,15 +575,11 @@ if ($mode == 'other') {
print ajax_constantonoff("MAIN_HELP_DISABLELINK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other');
//print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Disable javascript and ajax
print '<tr class="oddeven"><td>' . $langs->trans("DisableJavascript") . '</td><td>';
print '<tr class="oddeven"><td>' . $form->textwithpicto($langs->trans("DisableJavascript"), $langs->trans("DisableJavascriptNote")) . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_JAVASCRIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other');
print ' <span class="opacitymedium paddingleft marginleft">' . $langs->trans("DisableJavascriptNote") . '</span>';
print '</td>';
print '<td>';
print '</td>';
print '</tr>';

View File

@ -403,7 +403,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -545,7 +545,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -169,7 +169,7 @@ if (empty($reshook)) {
foreach ($object->fields as $key => $val) {
$search[$key] = '';
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

View File

@ -66,10 +66,6 @@ $search_lang = GETPOST('search_lang', 'alpha');
$search_fk_user = GETPOST('search_fk_user', 'intcomma');
$search_topic = GETPOST('search_topic', 'alpha');
if (!empty($user->socid)) {
accessforbidden();
}
$acts = array();
$actl = array();
$acts[0] = "activate";
@ -100,6 +96,7 @@ if (empty($sortorder)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('emailtemplates'));
// Name of SQL tables of dictionaries
$tabname = array();
$tabname[25] = MAIN_DB_PREFIX."c_email_templates";
@ -246,6 +243,12 @@ if ($reshook == 0) {
}
}
if (!empty($user->socid)) {
accessforbidden();
}
$permissiontoadd = 1;
//asort($elementList);
@ -273,6 +276,9 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// All tests are required to be compatible with all browsers
@ -281,7 +287,7 @@ if (empty($reshook)) {
$search_lang = '';
$search_fk_user = '';
$search_topic = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
@ -395,7 +401,7 @@ if (empty($reshook)) {
}
} elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
} elseif (in_array($keycode, array('joinfiles', 'private', 'position'))) {
} elseif (in_array($keycode, array('joinfiles', 'private', 'position', 'entity'))) {
$sql .= (int) GETPOST($keycode, 'int');
} else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
@ -502,9 +508,9 @@ if (empty($reshook)) {
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
$rowidcol = "rowid";
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."=".((int) $rowid);
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
if (!$user->admin) { // A non admin user can only edit its own template
$sql .= " AND fk_user = ".((int) $user->id);
$sql .= " AND fk_user = ".((int) $user->id);
}
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
@ -548,47 +554,20 @@ if (empty($reshook)) {
*/
$form = new Form($db);
$now = dol_now();
$formadmin = new FormAdmin($db);
//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
$help_url = '';
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
$title = $langs->trans("EMailsSetup");
} else {
$title = $langs->trans("EMailsTemplates");
$title = $langs->trans("EMailTemplates");
}
llxHeader('', $title, $help_url);
$linkback = '';
$titlepicto = 'title_setup';
$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add';
$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre($title, '', $titlepicto);
} else {
print load_fiche_titre($title, $newcardbutton, $titlepicto);
}
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
$head = email_admin_prepare_head();
print dol_get_fiche_head($head, 'templates', '', -1);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre('', $newcardbutton, '');
}
}
// Confirmation de la suppression de la ligne
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
$morejs = array();
$morecss = array();
$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates";
@ -623,6 +602,78 @@ $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
//print $sql;
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($mode)) {
$param .= '&mode='.urlencode($mode);
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
if ($skey != '') {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
}
} elseif ($search[$key] != '') {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
$linkback = '';
$titlepicto = 'title_setup';
$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add&token='.newToken();
$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre($title, '', $titlepicto);
} else {
print load_fiche_titre($title, $newcardbutton, $titlepicto);
}
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
$head = email_admin_prepare_head();
print dol_get_fiche_head($head, 'templates', '', -1);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre('', $newcardbutton, '');
}
}
// Confirmation de la suppression de la ligne
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
$fieldlist = explode(',', $tabfield[$id]);
if ($action == 'add') {
@ -681,7 +732,7 @@ if ($action == 'add') {
}
if ($valuetoshow != '') {
print '<td class="'.$align.'">';
print '<th class="'.$align.'">';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
print '<a href="'.$tabhelp[$id][$value].'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
} elseif (!empty($tabhelp[$id][$value])) {
@ -693,12 +744,12 @@ if ($action == 'add') {
} else {
print $valuetoshow;
}
print '</td>';
print '</th>';
}
}
print '<td>';
print '<th>';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>';
print '</th>';
print '</tr>';
$obj = new stdClass();
@ -742,7 +793,7 @@ if ($action == 'add') {
$fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
}
foreach ($fieldsforcontent as $tmpfieldlist) {
print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
print '<tr class="impair nodrag nodrop nohover"><td colspan="7" class="nobottom">';
// Label
if ($tmpfieldlist == 'topic') {
@ -769,28 +820,37 @@ if ($action == 'add') {
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
$okforextended = false;
}
$doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%');
$doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_4, '90%');
print $doleditor->Create(1);
}
print '</td>';
if ($tmpfieldlist == 'topic') {
print '<td class="center" rowspan="'.(count($fieldsforcontent)).'">';
if ($action != 'edit') {
print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
}
print '</td>';
}
// else print '<td></td>';
print '</tr>';
}
print '</table>';
if ($action != 'edit') {
print '<center>';
print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"> ';
print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</center>';
}
print '</div>';
print '</form>';
print '<br>';
print '<br><br>';
} // END IF not edit
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
@ -798,157 +858,155 @@ print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('fro
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$i = 0;
$param = '&id='.$id;
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_lang > 0) {
$param .= '&search_lang='.urlencode($search_lang);
}
if ($search_type_template != '-1') {
$param .= '&search_type_template='.urlencode($search_type_template);
}
if ($search_fk_user > 0) {
$param .= '&search_fk_user='.urlencode($search_fk_user);
}
if ($search_topic) {
$param .= '&search_topic='.urlencode($search_topic);
}
$param = '&id='.$id;
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_lang > 0) {
$param .= '&search_lang='.urlencode($search_lang);
}
if ($search_type_template != '-1') {
$param .= '&search_type_template='.urlencode($search_type_template);
}
if ($search_fk_user > 0) {
$param .= '&search_fk_user='.urlencode($search_fk_user);
}
if ($search_topic) {
$param .= '&search_topic='.urlencode($search_topic);
}
$paramwithsearch = $param;
if ($sortorder) {
$paramwithsearch .= '&sortorder='.urlencode($sortorder);
}
if ($sortfield) {
$paramwithsearch .= '&sortfield='.urlencode($sortfield);
}
if (GETPOST('from', 'alpha')) {
$paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
}
$paramwithsearch = $param;
if ($sortorder) {
$paramwithsearch .= '&sortorder='.urlencode($sortorder);
}
if ($sortfield) {
$paramwithsearch .= '&sortfield='.urlencode($sortfield);
}
if (GETPOST('from', 'alpha')) {
$paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
}
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
// Title line with search boxes
print '<tr class="liste_titre">';
// Title line with search boxes
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
if ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).'"></td>';
} elseif ($value == 'lang') {
print '<td class="liste_titre">';
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150');
print '</td>';
} elseif ($value == 'fk_user') {
print '<td class="liste_titre">';
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150');
print '</td>';
} elseif ($value == 'topic') {
print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
} elseif ($value == 'type_template') {
print '<td class="liste_titre center">';
print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1);
print '</td>';
} elseif (!in_array($value, array('content', 'content_lines'))) {
print '<td class="liste_titre"></td>';
}
}
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
foreach ($fieldlist as $field => $value) {
if ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).'"></td>';
} elseif ($value == 'lang') {
print '<td class="liste_titre">';
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150');
print '</td>';
} elseif ($value == 'fk_user') {
print '<td class="liste_titre">';
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150');
print '</td>';
} elseif ($value == 'topic') {
print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
} elseif ($value == 'type_template') {
print '<td class="liste_titre center">';
print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1);
print '</td>';
} elseif (!in_array($value, array('content', 'content_lines'))) {
print '<td class="liste_titre"></td>';
}
}
// Action column
print '<td class="liste_titre right" width="64">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
print '<td class="liste_titre"></td>';
}
// Title of lines
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
$showfield = 1; // By defaut
$align = "left";
$sortable = 1;
$valuetoshow = '';
$forcenowrap = 1;
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'fk_user') {
$valuetoshow = $langs->trans("Owner");
}
if ($fieldlist[$field] == 'lang') {
$valuetoshow = $langs->trans("Language");
}
if ($fieldlist[$field] == 'type') {
$valuetoshow = $langs->trans("Type");
}
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field] == 'type_template') {
$align = 'center';
$valuetoshow = $langs->trans("TypeOfTemplate");
}
if ($fieldlist[$field] == 'private') {
$align = 'center';
}
if ($fieldlist[$field] == 'position') {
$align = 'center';
}
// Action column
print '<td class="liste_titre right" width="64">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
if ($fieldlist[$field] == 'joinfiles') {
$valuetoshow = $langs->trans("FilesAttachedToEmail"); $align = 'center'; $forcenowrap = 0;
}
if ($fieldlist[$field] == 'content') {
$valuetoshow = $langs->trans("Content"); $showfield = 0;
}
if ($fieldlist[$field] == 'content_lines') {
$valuetoshow = $langs->trans("ContentForLines"); $showfield = 0;
}
// Show fields
if ($showfield) {
if (!empty($tabhelp[$id][$value])) {
if (in_array($value, array('topic'))) {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
} else {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
}
}
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder);
}
// Title of lines
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
$showfield = 1; // By defaut
$align = "left";
$sortable = 1;
$valuetoshow = '';
$forcenowrap = 1;
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'fk_user') {
$valuetoshow = $langs->trans("Owner");
}
if ($fieldlist[$field] == 'lang') {
$valuetoshow = $langs->trans("Language");
}
if ($fieldlist[$field] == 'type') {
$valuetoshow = $langs->trans("Type");
}
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field] == 'type_template') {
$align = 'center';
$valuetoshow = $langs->trans("TypeOfTemplate");
}
if ($fieldlist[$field] == 'private') {
$align = 'center';
}
if ($fieldlist[$field] == 'position') {
$align = 'center';
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList('');
print '</tr>';
if ($fieldlist[$field] == 'joinfiles') {
$valuetoshow = $langs->trans("FilesAttachedToEmail"); $align = 'center'; $forcenowrap = 0;
}
if ($fieldlist[$field] == 'content') {
$valuetoshow = $langs->trans("Content"); $showfield = 0;
}
if ($fieldlist[$field] == 'content_lines') {
$valuetoshow = $langs->trans("ContentForLines"); $showfield = 0;
}
if ($num) {
// Lines with values
while ($i < $num) {
$obj = $db->fetch_object($resql);
// Show fields
if ($showfield) {
if (!empty($tabhelp[$id][$value])) {
if (in_array($value, array('topic'))) {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
} else {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
}
}
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder);
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList('');
print '</tr>';
if ($num) {
$nbqualified = 0;
// Lines with values
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj) {
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
@ -1000,7 +1058,7 @@ if ($resql) {
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
$okforextended = false;
}
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_6, '90%');
print $doleditor->Create(1);
}
if ($tmpfieldlist == 'content_lines') {
@ -1018,6 +1076,8 @@ if ($resql) {
}
print "</tr>\n";
$nbqualified++;
} else {
// If template is for a module, check module is enabled.
if ($obj->module) {
@ -1039,6 +1099,8 @@ if ($resql) {
continue; // Email template not qualified
}
$nbqualified++;
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
$tmpaction = 'view';
@ -1152,15 +1214,19 @@ if ($resql) {
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
}
print '</td>';
print "</tr>\n";
}
$i++;
}
$i++;
}
} else {
dol_print_error($db);
}
// If no record found
if ($nbqualified == 0) {
$colspan = 10;
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
print '</table>';

View File

@ -172,6 +172,10 @@ foreach ($modulesdir as $dir) {
$moduleposition = '80'; // External modules at end by default
}
if (empty($familyinfo[$familykey]['position'])) {
$familyinfo[$familykey]['position'] = '0';
}
$orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
$dirmod[$i] = $dir;
//print $i.'-'.$dirmod[$i].'<br>';
@ -250,19 +254,19 @@ if (!empty($conf->global->$const_name)) {
$text .= $langs->trans("Disabled");
}
$tmp = $objMod->getLastActivationInfo();
$authorid = $tmp['authorid'];
$authorid = (empty($tmp['authorid']) ? '' : $tmp['authorid']);
if ($authorid > 0) {
$tmpuser = new User($db);
$tmpuser->fetch($authorid);
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationAuthor").':</span> ';
$text .= $tmpuser->getNomUrl(1);
}
$ip = $tmp['ip'];
$ip = (empty($tmp['ip']) ? '' : $tmp['ip']);
if ($ip) {
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationIP").':</span> ';
$text .= $ip;
}
$lastactivationversion = $tmp['lastactivationversion'];
$lastactivationversion = (empty($tmp['lastactivationversion']) ? '' : $tmp['lastactivationversion']);
if ($lastactivationversion) {
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationVersion").':</span> ';
$text .= $lastactivationversion;

View File

@ -481,9 +481,9 @@ $deschelp = '';
if ($mode == 'common' || $mode == 'commonkanban') {
$desc = $langs->trans("ModulesDesc", '{picto}');
$desc .= ' '.$langs->trans("ModulesDesc2", '{picto2}');
$desc = str_replace('{picto}', img_picto('', 'switch_off'), $desc);
$desc = str_replace('{picto2}', img_picto('', 'setup'), $desc);
if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled
$desc = str_replace('{picto}', img_picto('', 'switch_off', 'class="size15x"'), $desc);
$desc = str_replace('{picto2}', img_picto('', 'setup', 'class="size15x"'), $desc);
if (!count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled
$deschelp = '<div class="info hideonsmartphone">'.$desc."<br></div><br>\n";
}
}

View File

@ -1,9 +1,10 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Bahfir Abbes <contact@dolibarrpar.org>
* Copyright (C) 2020 Thibault FOUCART <suport@ptibogxiv.net>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -267,7 +268,8 @@ $constantes = array();
foreach ($listofnotifiedevents as $notifiedevent) {
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
$model = $notifiedevent['elementtype'].'_send';
$model = $notifiedevent['elementtype'];
if ($notifiedevent['elementtype'] == 'order_supplier') {
$elementLabel = $langs->trans('SupplierOrder');

View File

@ -309,7 +309,7 @@ print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Par
// Show sender name
/* Set option as hidden because no need of this for 99.99% of users.
/* Set option as hidden because no need of this for 99.99% of users. Having it as hidden feature is enough.
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").'</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME');
@ -321,7 +321,7 @@ print '</td></tr>';
// Hide VAT Intra on address
print '<tr class="oddeven"><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td>';
print '<tr class="oddeven"><td>'.$langs->trans("ShowVATIntaInAddress").' - <span class="opacitymedium">'.$langs->trans("ThirdPartyAddress").'</span></td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('MAIN_TVAINTRA_NOT_IN_ADDRESS');
} else {
@ -340,7 +340,7 @@ for ($i = 1; $i <= 6; $i++) {
$pid = img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
}
if ($pid) {
print '<tr class="oddeven"><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid.'</td><td>';
print '<tr class="oddeven"><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid.' - <span class="opacitymedium">'.$langs->trans("ThirdPartyAddress").'</span></td><td>';
$keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff($keyforconstant);

View File

@ -435,7 +435,8 @@ foreach ($configfileparameters as $key => $value) {
if (empty($valuetoshow)) {
print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id');
}
print ' &nbsp; <span class="opacitymedium">('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')</span>';
print '</td></tr>';
print '<tr class="oddeven"><td></td><td>&nbsp; => '.$langs->trans("HashForPing").'</td><td>'.md5('dolibarr'.$valuetoshow).'</td></tr>'."\n";
} elseif ($newkey == 'dolibarr_main_prod') {
print ${$newkey};

View File

@ -266,10 +266,20 @@ print '<br>';
print '<strong>$dolibarr_main_restrict_ip</strong>: ';
if (empty($dolibarr_main_restrict_ip)) {
print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
print $langs->trans("None");
//print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
} else {
print $dolibarr_main_restrict_ip;
}
print '<br>';
print '<strong>$dolibarr_main_restrict_os_commands</strong>: ';
if (empty($dolibarr_main_restrict_os_commands)) {
print $langs->trans("None");
} else {
print $dolibarr_main_restrict_os_commands;
}
print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore').')</span>';
print '<br>';
if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) {

View File

@ -26,6 +26,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php";
require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php";
require_once DOL_DOCUMENT_ROOT."/core/class/html.formcategory.class.php";
// Load translation files required by the page
$langs->loadLangs(array("admin", "ticket"));
@ -102,10 +103,11 @@ if ($action == 'updateMask') {
include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
$notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
$notification_email_description = "Sender of ticket replies sent from Dolibarr";
if (!empty($notification_email)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, $notification_email_description, $conf->entity);
} else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $conf->global->MAIN_MAIL_EMAIL_FROM, 'chaine', 0, $notification_email_description, $conf->entity);
}
if (!($res > 0)) {
$error++;
@ -113,30 +115,33 @@ if ($action == 'updateMask') {
// altairis : differentiate notification email FROM and TO
$notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
$notification_email_to_description = "Notified e-mail for ticket replies sent from Dolibarr";
if (!empty($notification_email_to)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, $notification_email_to_description, $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, $notification_email_to_description, $conf->entity);
}
if (!($res > 0)) {
$error++;
}
$mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml');
$mail_intro_description = "Introduction text of ticket replies sent from Dolibarr";
if (!empty($mail_intro)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, $mail_intro_description, $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', '', 'chaine', 0, $mail_intro_description, $conf->entity);
}
if (!($res > 0)) {
$error++;
}
$mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml');
$signature_description = "Signature of ticket replies sent from Dolibarr";
if (!empty($mail_signature)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, $signature_description, $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', '', 'chaine', 0, $signature_description, $conf->entity);
}
if (!($res > 0)) {
$error++;
@ -157,6 +162,14 @@ if ($action == 'setvarworkflow') {
}
}
if ($action == 'setvarworkflowother' || $action == 'setvarworkflow') {
$param_ticket_product_category = GETPOST('product_category_id', 'int');
$res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
if ($action == 'setvarother') {
$param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
@ -219,7 +232,7 @@ if ($action == 'setvarother') {
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
$form = new Form($db);
$formcategory = new FormCategory($db);
$help_url = "FR:Module_Ticket";
$page_name = "TicketSetup";
@ -326,7 +339,7 @@ foreach ($dirmodels as $reldir) {
}
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
print '</tr>';
@ -464,7 +477,7 @@ foreach ($dirmodels as $reldir) {
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
// Preview
@ -489,8 +502,7 @@ foreach ($dirmodels as $reldir) {
print '</table>';
print '</div><br>';
if (!$conf->use_javascript_ajax) {
if (empty($conf->use_javascript_ajax)) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarworkflow">';
@ -512,11 +524,11 @@ if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help');
print '</td>';
print '</tr>';
@ -528,11 +540,11 @@ if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help');
print '</td>';
print '</tr>';
@ -543,18 +555,33 @@ if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING);
print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, 'help');
print '</td>';
print '</tr>';
if (!$conf->use_javascript_ajax) {
print '</form>';
// Choose which product category is used for tickets
if ($conf->use_javascript_ajax) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarworkflowother">';
}
print '<tr class="oddeven"><td>'.$langs->trans("TicketChooseProductCategory").'</td>';
print '<td class="left">';
$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id');
if ($conf->use_javascript_ajax) {
print ajax_combobox('select_'.$htmlname);
}
print '</td>';
print '<td class="center">';
print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Define wanted maximum time elapsed before answers to tickets
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="action" value="setvarother">';
@ -566,7 +593,7 @@ print '<td class="left">
<input type="submit" class="button small" value="'.$langs->trans("Save").'">
</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help');
print '</td>';
print '</tr>';
@ -577,14 +604,18 @@ print '<td class="left">
<input type="submit" class="button small" value="'.$langs->trans("Save").'">
</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help');
print '</td>';
print '</tr>';
print '</form>';
print '</table><br>';
print '<div class="center">';
print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
// Admin var of module
print load_fiche_titre($langs->trans("Notification"), '', '');
@ -612,16 +643,16 @@ print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationFrom").'<
print '<td class="left">';
print '<input type="text" class="minwidth200" name="TICKET_NOTIFICATION_EMAIL_FROM" value="'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'"></td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Email for notification of TICKET_CREATE
print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").' ('.$langs->trans("Creation").')</td>';
print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").'</td>';
print '<td class="left">';
print '<input type="text" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : '').'"></td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
print '</td>';
print '</tr>';
@ -633,25 +664,25 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
print $formcategory->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
print '</td>';
print '</tr>';
}
// Texte d'introduction
$mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntroLabelAdmin").' ('.$langs->trans("Responses").')';
print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntroLabelAdmin");
print '</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help');
print '</td></tr>';
// Texte de signature
@ -663,12 +694,12 @@ $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '10
$doleditor->Create();
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help');
print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help');
print '</td></tr>';
print '</table>';
print $form->buttonsSaveCancel("Save", '');
print $formcategory->buttonsSaveCancel("Save", '');
print '</form>';

View File

@ -90,7 +90,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$transkey = '';
$transvalue = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
@ -271,7 +271,8 @@ $recordtoshow = array();
// Search modules dirs
$modulesdir = dolGetModulesDirs();
$nbtotaloffiles = 0;
$listoffiles = array();
$listoffilesexternalmodules = array();
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
$i = 0;
@ -298,7 +299,10 @@ foreach ($modulesdir as $keydir => $tmpsearchdir) {
if ($result < 0) {
print 'Failed to load language file '.$tmpfile.'<br>'."\n";
} else {
$nbtotaloffiles++;
$listoffiles[$langkey] = $tmpfile;
if (strpos($langkey, '@') !== false) {
$listoffilesexternalmodules[$langkey] = $tmpfile;
}
}
//print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
@ -307,6 +311,8 @@ foreach ($modulesdir as $keydir => $tmpsearchdir) {
$i++;
}
$nbtotaloffiles = count($listoffiles);
$nbtotaloffilesexternal = count($listoffilesexternalmodules);
if ($mode == 'overwrite') {
print '<input type="hidden" name="page" value="'.$page.'">';
@ -358,7 +364,7 @@ if ($mode == 'overwrite') {
print '</td>';
print '<td class="center">';
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnabledTranslationOverwriteBefore")).'">';
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnableTranslationOverwriteBefore")).'">';
print "</td>\n";
print '</tr>';
@ -477,7 +483,7 @@ if ($mode == 'searchkey') {
//print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
$title = $langs->trans("Translation");
if ($nbtotalofrecords > 0) {
$title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')</span>';
$title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - <span title="'.dol_escape_htmltag(($nbtotaloffiles - $nbtotaloffilesexternal).' core - '.($nbtotaloffilesexternal).' external').'">'.$nbtotaloffiles.' '.$langs->trans("Files").'</span>)</span>';
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);

View File

@ -113,7 +113,7 @@ $tabcond[1] = (!empty($conf->website->enabled));
// List of help for fields
$tabhelp = array();
$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'));
$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/<i>websiteref</i>'));
// List of check for fields (NOT USED YET)
$tabfieldcheck = array();
@ -271,8 +271,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
if ($resql) {
$newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09'));
if ($newname != $website->ref) {
$srcfile = DOL_DATA_ROOT.'/website/'.$website->ref;
$destfile = DOL_DATA_ROOT.'/website/'.$newname;
$srcfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website->ref;
$destfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$newname;
if (dol_is_dir($destfile)) {
$error++;

View File

@ -71,6 +71,12 @@ $workflowcodes = array(
'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)),
'picto'=>'bill'
),
'WORKFLOW_TICKET_CREATE_INTERVENTION' => array (
'family'=>'create',
'position'=>25,
'enabled'=>(!empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)),
'picto'=>'ticket'
),
'separator1'=>array('family'=>'separator', 'position'=>25, 'title'=>''),
@ -161,7 +167,21 @@ $workflowcodes = array(
'position' => 90,
'enabled' => ! empty($conf->expedition->enabled) && ! empty($conf->facture->enabled),
'picto' => 'shipment'
)
),
// Automatic link ticket -> contract
'WORKFLOW_TICKET_LINK_CONTRACT' => array(
'family' => 'link_ticket',
'position' => 75,
'enabled' => ! empty($conf->ticket->enabled) && ! empty($conf->contract->enabled),
'picto' => 'ticket'
),
'WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS' => array(
'family' => 'link_ticket',
'position' => 76,
'enabled' => ! empty($conf->ticket->enabled) && ! empty($conf->contract->enabled),
'picto' => 'ticket'
),
);
if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) {
@ -237,6 +257,11 @@ foreach ($workflowcodes as $key => $params) {
if ($reg[1] == 'shipping') {
$header .= ' - '.$langs->trans('Shipment');
}
} elseif (preg_match('/link_(.*)/', $params['family'], $reg)) {
$header = $langs->trans("AutomaticLinking");
if ($reg[1] == 'ticket') {
$header .= ' - '.$langs->trans('Ticket');
}
} else {
$header = $langs->trans("Description");
}

View File

@ -295,7 +295,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -437,7 +437,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';

View File

@ -458,6 +458,20 @@ class Documents extends DolibarrApi
}
$upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref);
} elseif ($modulepart == 'knowledgemanagement') {
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
throw new RestException(401);
}
$object = new KnowledgeRecord($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'KM article not found');
}
$upload_dir = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.dol_sanitizeFileName($object->ref);
} elseif ($modulepart == 'categorie' || $modulepart == 'category') {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
@ -597,6 +611,16 @@ class Documents extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$object = new FactureFournisseur($this->db);
} elseif ($modulepart == 'commande' || $modulepart == 'order') {
$modulepart = 'commande';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$object = new Commande($this->db);
} elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') {
$modulepart = 'supplier_order';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$object = new CommandeFournisseur($this->db);
} elseif ($modulepart == 'project') {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$object = new Project($this->db);
@ -655,7 +679,7 @@ class Documents extends DolibarrApi
}
// Special cases that need to use get_exdir to get real dir of object
// If future, all object should use this to define path of documents.
// In future, all object should use this to define path of documents.
if ($modulepart == 'supplier_invoice') {
$tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier');
}

View File

@ -266,7 +266,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -408,7 +408,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -286,7 +286,7 @@ if ($conf->product->enabled || $conf->product->service) {
print '<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans("InitEmptyBarCode", min($maxperinit, $nbno)).'"'.$moretags1.'>';
$moretags2 = (($nbno == $nbtotal) ? ' disabled' : '');
print ' &nbsp; ';
print '<input type="submit" class="button" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretags2.' onClick="return confirm_erase();">';
print '<input type="submit" class="button butActionDelete" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretags2.' onClick="return confirm_erase();">';
print '<br><br><br><br>';
}

View File

@ -118,7 +118,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = '';
$search_amount = '';
$search_showonlyerrors = 0;
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -1103,6 +1103,23 @@ class BOM extends CommonObject
}
}
/**
* Function used to replace a product id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old product id
* @param int $dest_id New product id
* @return bool
*/
public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'bom_bomline'
);
return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
}
/**
* Get Net needs by product
*

View File

@ -1141,10 +1141,10 @@ class Categorie extends CommonObject
}
// We add the fullpath property to each elements of first level (no parent exists)
dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG);
foreach ($this->cats as $key => $val) {
//print 'key='.$key.'<br>'."\n";
$this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent)
$this->buildPathFromId($key, 0); // Process a branch from the root category key (this category has no parent)
}
// Include or exclude leaf including $markafterid from tree
@ -1174,7 +1174,6 @@ class Categorie extends CommonObject
return $this->cats;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel.
* It is called by get_full_arbo()
@ -1185,19 +1184,18 @@ class Categorie extends CommonObject
* @return void
* @see get_full_arbo()
*/
public function build_path_from_id_categ($id_categ, $protection = 1000)
private function buildPathFromId($id_categ, $protection = 1000)
{
// phpcs:enable
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
//dol_syslog(get_class($this)."::buildPathFromId id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
if (!empty($this->cats[$id_categ]['fullpath'])) {
// Already defined
dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
dol_syslog(get_class($this)."::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING);
return;
}
// First build full array $motherof
//$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ
//$this->load_motherof(); // Disabled because already done by caller of buildPathFromId
// $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel

View File

@ -734,9 +734,9 @@ if ($type == Categorie::TYPE_MEMBER) {
print '<input type="hidden" name="action" value="addintocategory">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddMemberIntoCategory").' &nbsp;';
print $langs->trans("AssignCategoryTo").' &nbsp;';
print $form->selectMembers('', 'elemid');
print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
print '</tr>';
print '</table>';
print '</form>';

View File

@ -701,7 +701,7 @@ if (empty($reshook) && $action == 'update') {
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
$object->loadReminders();
$object->loadReminders($remindertype, 0, false);
if (!empty($object->reminders) && $object->datep > dol_now()) {
foreach ($object->reminders as $reminder) {
$reminder->delete($user);

View File

@ -778,7 +778,7 @@ class ActionComm extends CommonObject
$sql .= " a.fk_contact, a.percent as percentage,";
$sql .= " a.fk_element as elementid, a.elementtype,";
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency,";
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_sender, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
$sql .= " c.id as type_id, c.type as type_type, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
$sql .= " s.nom as socname,";
$sql .= " u.firstname, u.lastname as lastname,";
@ -868,6 +868,16 @@ class ActionComm extends CommonObject
$this->event_paid = $obj->event_paid;
$this->status = $obj->status;
//email information
$this->email_msgid=$obj->email_msgid;
$this->email_from=$obj->email_from;
$this->email_sender=$obj->email_sender;
$this->email_to=$obj->email_to;
$this->email_tocc=$obj->email_tocc;
$this->email_tobcc=$obj->email_tobcc;
$this->email_subject=$obj->email_subject;
$this->errors_to=$obj->errors_to;
$this->fetch_optionals();
if ($loadresources) {
@ -1582,8 +1592,25 @@ class ActionComm extends CommonObject
if (isset($this->transparency)) {
$tooltip .= '<br><b>'.$langs->trans('Busy').':</b> '.yn($this->transparency);
}
if (!empty($this->email_msgid)) {
$langs->load("mails");
$tooltip .= '<br>';
//$tooltip .= '<br><b>'.img_picto('', 'email').' '.$langs->trans("Email").'</b>';
$tooltip .= '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->email_subject;
$tooltip .= '<br><b>'.$langs->trans('MailFrom').':</b> '.str_replace(array('<', '>'), array('&amp;lt', '&amp;gt'), $this->email_from);
$tooltip .= '<br><b>'.$langs->trans('MailTo').':</b>, '.str_replace(array('<', '>'), array('&amp;lt', '&amp;gt'), $this->email_to);
if (!empty($this->email_tocc)) {
$tooltip .= '<br><b>'.$langs->trans('MailCC').':</b> '.str_replace(array('<', '>'), array('&amp;lt', '&amp;gt'), $this->email_tocc);
}
/* Disabled because bcc must remain by defintion not visible
if (!empty($this->email_tobcc)) {
$tooltip .= '<br><b>'.$langs->trans('MailCCC').':</b> '.$this->email_tobcc;
} */
}
if (!empty($this->note_private)) {
$tooltip .= '<br><b>'.$langs->trans('Note').':</b> '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '<br>', $this->note_private));
$tooltip .= '<br><br><b>'.$langs->trans('Description').':</b><br>';
$texttoshow = dolGetFirstLineOfText($this->note_private, 10);
$tooltip .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), '<br>', $texttoshow));
}
$linkclose = '';
//if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color)
@ -1594,9 +1621,8 @@ class ActionComm extends CommonObject
$label = $langs->trans("ShowAction");
$linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"';
$linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, 0, '', 1).'"';
$linkclose .= ' class="'.$classname.' classfortooltip"';
/*
$hookmanager->initHooks(array('actiondao'));
$parameters=array('id'=>$this->id);
@ -2210,6 +2236,26 @@ class ActionComm extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
/**
* Function used to replace a product id with another one.
*
* @param DoliDB $dbs Database handler
* @param int $origin_id Old product id
* @param int $dest_id New product id
* @return bool
*/
public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
{
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'actioncomm SET fk_element = ' . ((int) $dest_id) . ' WHERE elementtype="product" AND fk_element = '.((int) $origin_id);
// using $dbs, not $this->db because function is static
if (!$dbs->query($sql)) {
//$this->errors = $dbs->lasterror();
return false;
}
return true;
}
/**
* Is the action delayed?
*

View File

@ -25,6 +25,7 @@
* \brief File of class to parse ical calendars
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
/**
@ -39,6 +40,7 @@ class ICal
public $todo_count; // Number of Todos
public $freebusy_count; // Number of Freebusy
public $last_key; //Help variable save last key (multiline string)
public $error;
/**
@ -61,11 +63,15 @@ class ICal
$this->file = $file;
$file_text = '';
$tmparray = file($file);
if (is_array($tmparray)) {
$file_text = join("", $tmparray); //load file
$file_text = preg_replace("/[\r\n]{1,} /", "", $file_text);
$tmpresult = getURLContent($file, 'GET');
if ($tmpresult['http_code'] != 200) {
$file_text = '';
$this->error = 'Error: '.$tmpresult['http_code'].' '.$tmpresult['content'];
} else {
$file_text = preg_replace("/[\r\n]{1,} /", "", $tmpresult['content']);
}
//var_dump($tmpresult);
return $file_text; // return all text
}
@ -396,19 +402,19 @@ class ICal
public function get_event_list()
{
// phpcs:enable
return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : '');
return (empty($this->cal['VEVENT']) ? '' : $this->cal['VEVENT']);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return eventlist array (not sort eventlist array)
* Return freebusy array (not sort eventlist array)
*
* @return array
*/
public function get_freebusy_list()
{
// phpcs:enable
return $this->cal['VFREEBUSY'];
return (empty($this->cal['VFREEBUSY']) ? '' : $this->cal['VFREEBUSY']);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@ -277,12 +277,12 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) {
if (!empty($conf->global->$source) && !empty($conf->global->$name)) {
// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
$listofextcals[] = array(
'src'=>$conf->global->$source,
'name'=>$conf->global->$name,
'src' => getDolGlobalString($source),
'name' => getDolGlobalString($name),
'offsettz' => (!empty($conf->global->$offsettz) ? $conf->global->$offsettz : 0),
'color'=>$conf->global->$color,
'default'=>$conf->global->$default,
'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)
'color' => getDolGlobalString($color),
'default' => getDolGlobalString($default),
'buggedfile' => (isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)
);
}
}
@ -302,12 +302,12 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) {
if (!empty($user->conf->$source) && !empty($user->conf->$name)) {
// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
$listofextcals[] = array(
'src'=>$user->conf->$source,
'name'=>$user->conf->$name,
'src' => $user->conf->$source,
'name' => $user->conf->$name,
'offsettz' => (!empty($user->conf->$offsettz) ? $user->conf->$offsettz : 0),
'color'=>$user->conf->$color,
'default'=>$user->conf->$default,
'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)
'color' => $user->conf->$color,
'default' => $user->conf->$default,
'buggedfile' => (isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)
);
}
}
@ -397,7 +397,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) {
if ($resourceid > 0) {
$param .= "&search_resourceid=".urlencode($resourceid);
}
if ($status || GETPOSTISSET('status')) {
if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) {
$param .= "&search_status=".urlencode($status);
}
if ($filter) {
@ -622,7 +622,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"><label for="check_birthday"> <span class="check_birthday_text">'.$langs->trans("AgendaShowBirthdayEvents").'</span></label> &nbsp; </div>';
// Calendars from hooks
$parameters = array(); $object = null;
$parameters = array();
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
if (empty($reshook)) {
$s .= $hookmanager->resPrint;
@ -1033,8 +1033,8 @@ if ($resql) {
$event->type = 'holiday';
$event->type_picto = 'holiday';
$event->datep = $db->jdate($obj->date_start);
$event->datef = $db->jdate($obj->date_end);
$event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1);
$event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1;
$event->date_start_in_calendar = $event->datep;
$event->date_end_in_calendar = $event->datef;
@ -1213,7 +1213,7 @@ if (count($listofextcals)) {
$addevent = true;
} elseif (!is_array($icalevent['DTSTART'])) { // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch)
$datestart = $icalevent['DTSTART'];
$dateend = $icalevent['DTEND'];
$dateend = empty($icalevent['DTEND']) ? $datestart : $icalevent['DTEND'];
$datestart += +($offsettz * 3600);
$dateend += +($offsettz * 3600);

View File

@ -217,7 +217,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$dateend_dtstart = '';
$dateend_dtend = '';
$search_status = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -93,15 +93,15 @@ if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // I
}
$mode = 'show_pertype';
$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$resourceid = GETPOST("search_resourceid", "int") ? GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
$year = GETPOST("year", "int") ? GETPOST("year", "int") : date("Y");
$month = GETPOST("month", "int") ? GETPOST("month", "int") : date("m");
$week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W");
$day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d");
$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
$maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('search_actioncode', 'array')) {
@ -144,7 +144,7 @@ $tmparray = explode('-', $tmp);
$begin_d = 1;
$end_d = 53;
if ($status == '' && !GETPOSTISSET('status')) {
if ($status == '' && !GETPOSTISSET('search_status')) {
$status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
}
if (empty($mode) && !GETPOSTISSET('mode')) {
@ -164,6 +164,8 @@ if (GETPOST('viewyear', 'alpha') || $mode == 'show_year') {
$mode = 'show_year';
} // View by year
$object = new ActionComm($db);
// Load translation files required by the page
$langs->loadLangs(array('users', 'agenda', 'other', 'commercial'));
@ -175,6 +177,8 @@ if ($user->socid && $socid) {
$result = restrictedArea($user, 'societe', $socid);
}
$search_status = $status;
/*
* Actions
@ -276,7 +280,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) {
if ($resourceid > 0) {
$param .= "&search_resourceid=".urlencode($resourceid);
}
if ($status || GETPOSTISSET('status')) {
if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) {
$param .= "&search_status=".urlencode($status);
}
if ($filter) {
@ -402,7 +406,7 @@ if ($conf->use_javascript_ajax) {
//$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
// Calendars from hooks
$parameters = array(); $object = null;
$parameters = array();
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
if (empty($reshook)) {
$s .= $hookmanager->resPrint;

View File

@ -98,9 +98,9 @@ $year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
@ -153,9 +153,10 @@ if ($end_d < $begin_d) {
$end_d = $begin_d + 1;
}
if ($status == '' && !GETPOSTISSET('status')) {
if ($status == '' && !GETPOSTISSET('search_status')) {
$status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
}
if (empty($mode) && !GETPOSTISSET('mode')) {
$mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
}
@ -170,6 +171,8 @@ if (GETPOST('viewday', 'alpha') || $mode == 'show_day') {
$mode = 'show_day'; $day = ($day ? $day : date("d"));
} // View by day
$object = new ActionComm($db);
// Load translation files required by the page
$langs->loadLangs(array('users', 'agenda', 'other', 'commercial'));
@ -181,6 +184,8 @@ if ($user->socid && $socid) {
$result = restrictedArea($user, 'societe', $socid);
}
$search_status = $status;
/*
* Actions
@ -282,7 +287,8 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) {
if ($resourceid > 0) {
$param .= "&search_resourceid=".urlencode($resourceid);
}
if ($status || GETPOSTISSET('status')) {
if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) {
$param .= "&search_status=".urlencode($status);
}
if ($filter) {
@ -412,7 +418,7 @@ if ($conf->use_javascript_ajax) {
//$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
// Calendars from hooks
$parameters = array(); $object = null;
$parameters = array();
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
if (empty($reshook)) {
$s .= $hookmanager->resPrint;
@ -509,9 +515,7 @@ $s = $newtitle;
print $s;
print '<div class="liste_titre liste_titre_bydiv centpercent">';
if (empty($search_status)) {
$search_status = '';
}
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
print '</div>';

View File

@ -162,7 +162,8 @@ if (empty($reshook)) {
// set accountancy code
if ($action == 'setcustomeraccountancycode') {
$result = $object->fetch($id);
$object->code_compta = GETPOST("customeraccountancycode");
$object->code_compta_client = GETPOST("customeraccountancycode");
$object->code_compta = $object->code_compta_client; // For Backward compatibility
$result = $object->update($object->id, $user, 1, 1, 0);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -360,9 +361,9 @@ if ($object->id > 0) {
print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);
print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
print '</td><td>';
print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);
print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
print '</td>';
print '</tr>';
}
@ -686,7 +687,7 @@ if ($object->id > 0) {
}
print '</div><div class="fichehalfright">';
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner underbanner-before-box clearboth"></div>';
$boxstat = '';
@ -694,7 +695,7 @@ if ($object->id > 0) {
$MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
// Lien recap
$boxstat .= '<div class="box">';
$boxstat .= '<div class="box box-halfright">';
$boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
$boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';

View File

@ -103,7 +103,7 @@ if (empty($reshook)) {
}*/
$search_ref = '';
$search_all = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

View File

@ -14,6 +14,7 @@
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -80,6 +81,7 @@ $confirm = GETPOST('confirm', 'alpha');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -116,7 +118,7 @@ $usercandelete = $user->rights->propal->supprimer;
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send);
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
$usercancreateorder = $user->rights->commande->creer;
$usercancreateinvoice = $user->rights->facture->creer;
@ -879,6 +881,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
// Define vat_rate
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
@ -1196,7 +1205,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
if ($result > 0) {
$db->commit();
@ -1627,19 +1636,19 @@ if ($action == 'create') {
print '<table class="border centpercent">';
// Reference
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>';
print '<tr class="field_ref"><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td class="valuefieldcreate">'.$langs->trans("Draft").'</td></tr>';
// Ref customer
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
print '<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans('RefCustomer').'</td><td class="valuefieldcreate">';
print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>';
print '</tr>';
// Third party
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>';
print '<tr class="field_socid">';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans('Customer').'</td>';
$shipping_method_id = 0;
if ($socid > 0) {
print '<td>';
print '<td class="valuefieldcreate">';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
@ -1648,7 +1657,7 @@ if ($action == 'create') {
}
//$warehouse_id = $soc->warehouse_id;
} else {
print '<td>';
print '<td class="valuefieldcreate">';
print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
@ -1671,13 +1680,13 @@ if ($action == 'create') {
if ($socid > 0) {
// Contacts (ask contact only if thirdparty already defined).
print "<tr><td>".$langs->trans("DefaultContact").'</td><td>';
print '<tr class="field_contactid"><td class="titlefieldcreate">'.$langs->trans("DefaultContact").'</td><td class="valuefieldcreate">';
print img_picto('', 'contact');
print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, '', '', 0, 'minwidth300');
print '</td></tr>';
// Third party discounts info line
print '<tr><td>'.$langs->trans('Discounts').'</td><td>';
print '<tr class="field_discount_info"><td class="titlefieldcreate">'.$langs->trans('Discounts').'</td><td class="valuefieldcreate">';
$absolute_discount = $soc->getAvailableDiscounts();
@ -1689,12 +1698,12 @@ if ($action == 'create') {
}
// Date
print '<tr><td class="fieldrequired">'.$langs->trans('DatePropal').'</td><td>';
print '<tr class="field_addprop"><td class="titlefieldcreate fieldrequired">'.$langs->trans('DatePropal').'</td><td class="valuefieldcreate">';
print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
print '</td></tr>';
// Validaty duration
print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td>'.img_picto('', 'clock').'&ensp;<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>';
print '<tr class="field_duree_validitee"><td class="titlefieldcreate fieldrequired">'.$langs->trans("ValidityDuration").'</td><td class="valuefieldcreate">'.img_picto('', 'clock', 'class="paddingright"').'<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>';
// Terms of payment
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
@ -1703,31 +1712,31 @@ if ($action == 'create') {
print '</td></tr>';
// Mode of payment
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
print img_picto('', 'bank').'&ensp;';
print '<tr class="field_mode_reglement_id"><td class="titlefieldcreate">'.$langs->trans('PaymentMode').'</td><td class="valuefieldcreate">';
print img_picto('', 'bank', 'class="pictofixedwidth"');
$form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
// Bank Account
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
print '<tr class="field_fk_account"><td class="titlefieldcreate">'.$langs->trans('BankAccount').'</td><td class="valuefieldcreate">';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print '</td></tr>';
}
// Source / Channel - What trigger creation
print '<tr><td>'.$langs->trans('Source').'</td><td>';
print '<tr class="field_demand_reason_id"><td class="titlefieldcreate">'.$langs->trans('Source').'</td><td class="valuefieldcreate">';
print img_picto('', 'question', 'class="pictofixedwidth"');
$form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
// Delivery delay
print '<tr class="fielddeliverydelay"><td>'.$langs->trans('AvailabilityPeriod');
print '<tr class="field_availability_id"><td class="titlefieldcreate">'.$langs->trans('AvailabilityPeriod');
if (!empty($conf->commande->enabled)) {
print ' ('.$langs->trans('AfterOrder').')';
}
print '</td><td>';
print img_picto('', 'clock').'&ensp;';
print '</td><td class="valuefieldcreate">';
print img_picto('', 'clock', 'class="pictofixedwidth"');
$form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
@ -1736,7 +1745,7 @@ if ($action == 'create') {
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
$shipping_method_id = $soc->shipping_method_id;
}
print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>';
print '<tr class="field_shipping_method_id"><td class="titlefieldcreate">'.$langs->trans('SendingMethod').'</td><td class="valuefieldcreate">';
print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"');
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
@ -1746,14 +1755,14 @@ if ($action == 'create') {
if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
print '<tr><td>'.$langs->trans('Warehouse').'</td><td>';
print '<tr class="field_warehouse_id"><td class="titlefieldcreate">'.$langs->trans('Warehouse').'</td><td class="valuefieldcreate">';
print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}
// Delivery date (or manufacturing)
print '<tr><td>'.$langs->trans("DeliveryDate").'</td>';
print '<td>';
print '<tr class="field_date_livraison"><td class="titlefieldcreate">'.$langs->trans("DeliveryDate").'</td>';
print '<td class="valuefieldcreate">';
if (isset($conf->global->DATE_LIVRAISON_WEEK_DELAY) && is_numeric($conf->global->DATE_LIVRAISON_WEEK_DELAY)) {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$syear = date("Y", $tmpdte);
@ -1768,8 +1777,8 @@ if ($action == 'create') {
// Project
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td>';
print '<tr class="field_projectid">';
print '<td class="titlefieldcreate">'.$langs->trans("Project").'</td><td class="valuefieldcreate">';
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td>';
@ -1778,18 +1787,18 @@ if ($action == 'create') {
// Incoterms
if (!empty($conf->incoterm->enabled)) {
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).'</label></td>';
print '<td class="maxwidthonsmartphone">';
print '<tr class="field_incoterm_id">';
print '<td class="titlefieldcreate"><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).'</label></td>';
print '<td class="valuefieldcreate maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : ''));
print '</td></tr>';
}
// Template to use by default
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td>';
print img_picto('', 'pdf').'&ensp;';
print '<tr class="field_model">';
print '<td class="titlefieldcreate">'.$langs->trans("DefaultModel").'</td>';
print '<td class="valuefieldcreate">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
$liste = ModelePDFPropales::liste_modeles($db);
$preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : getDolGlobalString("PROPALE_ADDON_PDF"));
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
@ -1797,26 +1806,26 @@ if ($action == 'create') {
// Multicurrency
if (!empty($conf->multicurrency->enabled)) {
print '<tr>';
print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '<tr class="field_currency">';
print '<td class="titlefieldcreate">'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
print '<td class="valuefieldcreate maxwidthonsmartphone">';
print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '</td></tr>';
}
// Public note
print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top">';
print '<tr class="field_note_public">';
print '<td class="titlefieldcreate tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td class="valuefieldcreate">';
$note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null));
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
if (empty($user->socid)) {
print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top">';
print '<tr class="field_note_private">';
print '<td class="titlefieldcreate tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td class="valuefieldcreate">';
$note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
@ -1942,11 +1951,13 @@ if ($action == 'create') {
$title = $langs->trans('ProductsAndServices');
print load_fiche_titre($title);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$objectsrc->printOriginLinesList();
print '</table>';
print '</div>';
}
} elseif ($object->id > 0) {
/*
@ -1967,7 +1978,7 @@ if ($action == 'create') {
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300')),
array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans('PuttingPricesUpToDate'), 'value' => (!empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES) ? 1 : 0)),
);
if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) {
@ -2341,9 +2352,9 @@ if ($action == 'create') {
print '</tr>';
// Payment mode
print '<tr>';
print '<td class="valuefield">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<tr class="field_mode_reglement_id">';
print '<td class="titlefieldcreate">';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode' && $usercancreate && $caneditfield) {
@ -2362,7 +2373,7 @@ if ($action == 'create') {
$langs->load('deliveries');
print '<tr><td>';
print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker');
print '</td><td class="valuefield">';
print '</td><td class="valuefieldedit">';
print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker');
print '</td>';
print '</tr>';
@ -2393,7 +2404,7 @@ if ($action == 'create') {
// Shipping Method
if (!empty($conf->expedition->enabled)) {
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('SendingMethod');
print '</td>';
if ($action != 'editshippingmethod' && $usercancreate && $caneditfield) {
@ -2415,7 +2426,7 @@ if ($action == 'create') {
$langs->load('stocks');
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
print '<tr><td>';
print '<tr class="field_warehouse_id"><td class="titlefieldcreate">';
$editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td class="valuefieldcreate">';
@ -2430,7 +2441,7 @@ if ($action == 'create') {
// Origin of demand
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('Source');
print '</td>';
if ($action != 'editdemandreason' && $usercancreate) {

View File

@ -17,6 +17,7 @@
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2022 ATM Consulting <contact@atm-consulting.fr>
* Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -746,6 +747,11 @@ class Propal extends CommonObject
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
$linecount = count($this->lines);
for ($ii = $ranktouse; $ii <= $linecount; $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la propale meme
@ -1789,8 +1795,9 @@ class Propal extends CommonObject
*/
public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $filters = '')
{
global $langs, $conf;
// phpcs:enable
global $langs, $conf;
$this->lines = array();
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
@ -3827,8 +3834,24 @@ class Propal extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}
/**
* Function used to replace a product id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old product id
* @param int $dest_id New product id
* @return bool
*/
public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'propaldet'
);
return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
}
}
/**
* Class to manage commercial proposal lines
@ -4432,7 +4455,7 @@ class PropaleLigne extends CommonObjectLine
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEPROPAL_UPDATE', $user);
$result = $this->call_trigger('LINEPROPAL_MODIFY', $user);
if ($result < 0) {
$this->db->rollback();
return -1;

View File

@ -123,6 +123,15 @@ $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int');
$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int');
$search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
$search_date_signature_startday = GETPOST('search_date_signature_startday', 'int');
$search_date_signature_startmonth = GETPOST('search_date_signature_startmonth', 'int');
$search_date_signature_startyear = GETPOST('search_date_signature_startyear', 'int');
$search_date_signature_endday = GETPOST('search_date_signature_endday', 'int');
$search_date_signature_endmonth = GETPOST('search_date_signature_endmonth', 'int');
$search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int');
$search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear);
$search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear);
$search_status = GETPOST('search_status', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
@ -207,6 +216,7 @@ $arrayfields = array(
'p.date'=>array('label'=>"DatePropal", 'checked'=>1),
'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1),
'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0),
'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0),
'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0),
'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)),
'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1),
@ -330,13 +340,21 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_availability = '';
$search_status = '';
$object_statut = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$search_fk_cond_reglement = '';
$search_fk_shipping_method = '';
$search_fk_input_reason = '';
$search_fk_mode_reglement = '';
$search_date_signature_startday = '';
$search_date_signature_startmonth = '';
$search_date_signature_startyear = '';
$search_date_signature_endday = '';
$search_date_signature_endmonth = '';
$search_date_signature_endyear = '';
$search_date_signature_start = '';
$search_date_signature_end = '';
}
if ($object_statut != '') {
$search_status = $object_statut;
@ -361,7 +379,7 @@ if ($action == 'validate' && $permissiontovalidate) {
if ($tmpproposal->valid($user) > 0) {
setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs');
} else {
setEventMessage($langs->trans('CantBeValidated'), 'errors');
setEventMessage($tmpproposal->error, $tmpproposal->errors, 'errors');
$error++;
}
} else {
@ -398,7 +416,7 @@ if ($action == "sign" && $permissiontoclose) {
$error++;
}
} else {
setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors');
setEventMessage($langs->trans('MustBeValidatedToBeSigned', $tmpproposal->ref), 'errors');
$error++;
}
} else {
@ -517,6 +535,7 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= ' p.rowid, p.entity as propal_entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,';
$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql .= ' p.date_signature as dsignature,';
$sql .= ' p.note_public, p.note_private,';
$sql .= ' p.fk_cond_reglement,p.deposit_percent,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,';
$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
@ -701,6 +720,12 @@ if ($search_sale > 0) {
if ($search_user > 0) {
$sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user);
}
if ($search_date_signature_start) {
$sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'";
}
if ($search_date_signature_end) {
$sql .= " AND p.date_signature <= '".$db->idate($search_date_signature_end)."'";
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -917,6 +942,24 @@ if ($resql) {
if ($search_country) {
$param .= '&search_country='.urlencode($search_country);
}
if ($search_date_signature_startday) {
$param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday);
}
if ($search_date_signature_startmonth) {
$param .= '&search_date_signature_startmonth='.urlencode($search_date_signature_startmonth);
}
if ($search_date_signature_startyear) {
$param .= '&search_date_signature_startyear='.urlencode($search_date_signature_startyear);
}
if ($search_date_signature_endday) {
$param .= '&search_date_signature_endday='.urlencode($search_date_signature_endday);
}
if ($search_date_signature_endmonth) {
$param .= '&search_date_signature_endmonth='.urlencode($search_date_signature_endmonth);
}
if ($search_date_signature_endyear) {
$param .= '&search_date_signature_endyear='.urlencode($search_date_signature_endyear);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -1000,7 +1043,7 @@ if ($resql) {
$moreforfilter = '';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@ -1008,9 +1051,9 @@ if ($resql) {
$moreforfilter .= '</div>';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('LinkedToSpecificUsers');
$tmptitle = $langs->trans('LinkedToSpecificUsers');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
$moreforfilter .= '</div>';
}
@ -1148,6 +1191,17 @@ if ($resql) {
print '</div>';
print '</td>';
}
// Date Signature
if (!empty($arrayfields['p.date_signature']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '</td>';
}
// Availability
if (!empty($arrayfields['ava.rowid']['checked'])) {
print '<td class="liste_titre maxwidth100onsmartphone center">';
@ -1361,7 +1415,10 @@ if ($resql) {
print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['p.date_livraison']['checked'])) {
print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['p.date_signature']['checked'])) {
print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['ava.rowid']['checked'])) {
print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
@ -1720,6 +1777,18 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
// Date Signature
if (!empty($arrayfields['p.date_signature']['checked'])) {
if ($obj->dsignature) {
print '<td class="center">'.dol_print_date($db->jdate($obj->dsignature), 'day');
print '</td>';
} else {
print '<td>&nbsp;</td>';
}
if (!$i) {
$totalarray['nbfield']++;
}
}
// Availability
if (!empty($arrayfields['ava.rowid']['checked'])) {
print '<td class="center">';
@ -2028,7 +2097,7 @@ if ($resql) {
// Note public
if (!empty($arrayfields['p.note_public']['checked'])) {
print '<td class="center">';
print dol_escape_htmltag($obj->note_public);
print dol_string_nohtmltag($obj->note_public);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2037,7 +2106,7 @@ if ($resql) {
// Note private
if (!empty($arrayfields['p.note_private']['checked'])) {
print '<td class="center">';
print dol_escape_htmltag($obj->note_private);
print dol_string_nohtmltag($obj->note_private);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;

View File

@ -62,7 +62,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
exit;
}
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user->rights->societe->creer) {
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -153,7 +153,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user-
}
}
if ($action == 'setremise' && $user->rights->societe->creer) {
if ($action == 'setremise' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -192,7 +192,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) {
}
}
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $user->rights->societe->creer) {
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)

View File

@ -13,6 +13,7 @@
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -81,6 +82,7 @@ $contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -627,6 +629,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
// Define remise_percent
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) { // Add a new line
$langs->load('errors');
$error = 0;
@ -940,7 +949,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
if ($result > 0) {
$ret = $object->fetch($object->id); // Reload to get new records
@ -1723,7 +1732,7 @@ if ($action == 'create' && $usercancreate) {
// Terms of the settlement
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'paiment');
print img_picto('', 'paiment', 'class="pictofixedwidth"');
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', $deposit_percent);
print '</td></tr>';
@ -1812,10 +1821,10 @@ if ($action == 'create' && $usercancreate) {
// Template to use by default
print '<tr><td>'.$langs->trans('DefaultModel').'</td>';
print '<td>';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db);
$preselected = $conf->global->COMMANDE_ADDON_PDF;
print img_picto('', 'pdf', 'class="pictofixedwidth"');
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
@ -1824,7 +1833,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr>';
print '<td>'.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}
@ -1917,11 +1926,13 @@ if ($action == 'create' && $usercancreate) {
$title = $langs->trans('ProductsAndServices');
print load_fiche_titre($title);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$objectsrc->printOriginLinesList('', $selectedLines);
print '</table>';
print '</div>';
}
print '</form>';
@ -2199,7 +2210,7 @@ if ($action == 'create' && $usercancreate) {
if ($action == 'clone') {
// Create an array for form
$formquestion = array(
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)'))
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300'))
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
@ -2680,27 +2691,27 @@ if ($action == 'create' && $usercancreate) {
if (empty($reshook)) {
// Reopen a closed order
if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans('ReOpen').'</a>';
print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&amp;token='.newToken().'&amp;id='.$object->id, '');
}
// Send
if (empty($user->socid)) {
if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) {
if ($usercansend) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>';
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&amp;token='.newToken().'&amp;id='.$object->id.'&amp;mode=init#formmailbeforetitle', '');
} else {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a>';
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
// Valid
if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a>';
print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&amp;token='.newToken().'&amp;id='.$object->id, '');
}
// Edit
if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) {
print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a>';
print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=modif&amp;token='.newToken().'&amp;id='.$object->id, '');
}
// Create event
/*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD))
@ -2715,7 +2726,7 @@ if ($action == 'create' && $usercancreate) {
if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) {
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
if ($usercancreatepurchaseorder) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddPurchaseOrder").'</a>';
print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid, '');
}
}
}
@ -2726,9 +2737,9 @@ if ($action == 'create' && $usercancreate) {
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
if ($user->rights->ficheinter->creer) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddIntervention').'</a>';
print dolGetButtonAction('', $langs->trans('AddInterventionGR'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid, '');
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('AddIntervention').'</a>';
print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
@ -2738,7 +2749,7 @@ if ($action == 'create' && $usercancreate) {
$langs->load("contracts");
if ($user->rights->contrat->creer) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>';
print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid, '');
}
}
@ -2750,52 +2761,52 @@ if ($action == 'create' && $usercancreate) {
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) {
if ($user->rights->expedition->creer) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id.'">'.$langs->trans('CreateShipment').'</a>';
print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, '');
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('CreateShipment').'</a>';
print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
} else {
$langs->load("errors");
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Shipment"))).'">'.$langs->trans('CreateShipment').'</a>';
print dolGetButtonAction($langs->trans('ErrorModuleSetupNotComplete'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
// Set to shipped
if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=shipped">'.$langs->trans('ClassifyShipped').'</a>';
print dolGetButtonAction('', $langs->trans('ClassifyShipped'), 'default', $_SERVER["PHP_SELF"].'?action=shipped&amp;token='.newToken().'&amp;id='.$object->id, '');
}
// Create bill and Classify billed
// Note: Even if module invoice is not enabled, we should be able to use button "Classified billed"
if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) {
if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;token='.newToken().'&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid, '');
}
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("ClassifyBilled").'</a>';
print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&amp;token='.newToken().'&amp;id='.$object->id, '');
}
}
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifyunbilled&token='.newToken().'">'.$langs->trans("ClassifyUnBilled").'</a>';
print dolGetButtonAction('', $langs->trans('ClassifyUnBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifyunbilled&amp;token='.newToken().'&amp;id='.$object->id, '');
}
}
// Clone
if ($usercancreate) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object=order">'.$langs->trans("ToClone").'</a>';
print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&amp;token='.newToken().'&amp;id='.$object->id.'&amp;socid='.$object->socid, '');
}
// Cancel order
if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'">'.$langs->trans("Cancel").'</a>';
print dolGetButtonAction('', $langs->trans('Cancel'), 'danger', $_SERVER["PHP_SELF"].'?action=cancel&amp;token='.newToken().'&amp;id='.$object->id, '');
}
// Delete order
if ($usercandelete) {
if ($numshipping == 0) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>';
print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id, '');
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ShippingExist").'">'.$langs->trans("Delete").'</a>';
print dolGetButtonAction($langs->trans('ShippingExist'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}

View File

@ -135,6 +135,11 @@ class Orders extends DolibarrApi
// Add external contacts ids
$this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list);
$this->commande->fetchObjectLinked();
// Add online_payment_url, cf #20477
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$this->commande->online_payment_url = getOnlinePaymentUrl(0, 'order', $this->commande->ref);
return $this->_cleanObjectDatas($this->commande);
}
@ -230,6 +235,10 @@ class Orders extends DolibarrApi
if ($commande_static->fetch($obj->rowid)) {
// Add external contacts ids
$commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1);
// Add online_payment_url, cf #20477
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$commande_static->online_payment_url = getOnlinePaymentUrl(0, 'order', $commande_static->ref);
$obj_ret[] = $this->_cleanObjectDatas($commande_static);
}
$i++;
@ -735,6 +744,10 @@ class Orders extends DolibarrApi
$this->commande->fetchObjectLinked();
//fix #20477 : add online_payment_url
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$this->commande->online_payment_url = getOnlinePaymentUrl(0, 'order', $this->commande->ref);
return $this->_cleanObjectDatas($this->commande);
}

View File

@ -12,6 +12,7 @@
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2016-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -271,6 +272,11 @@ class Commande extends CommonOrder
*/
public $expeditions;
/**
* @var string payment url
*/
public $online_payment_url;
/**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
@ -1671,6 +1677,11 @@ class Commande extends CommonOrder
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
$linecount = count($this->lines);
for ($ii = $ranktouse; $ii <= $linecount; $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la commande meme
@ -2041,8 +2052,9 @@ class Commande extends CommonOrder
*/
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
global $langs, $conf;
// phpcs:enable
global $langs, $conf;
$this->lines = array();
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
@ -4044,6 +4056,23 @@ class Commande extends CommonOrder
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
/**
* Function used to replace a product id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old product id
* @param int $dest_id New product id
* @return bool
*/
public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'commandedet',
);
return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
}
/**
* Is the customer order delayed?
*
@ -4642,7 +4671,7 @@ class OrderLine extends CommonOrderLine
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEORDER_UPDATE', $user);
$result = $this->call_trigger('LINEORDER_MODIFY', $user);
if ($result < 0) {
$error++;
}

View File

@ -201,6 +201,7 @@ $arrayfields = array(
'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140),
'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995),
'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
);
// Extra fields
@ -266,7 +267,7 @@ if (empty($reshook)) {
$search_project = '';
$search_status = '';
$search_billed = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$search_datecloture_start = '';
@ -301,6 +302,352 @@ if (empty($reshook)) {
$uploaddir = $conf->commande->multidir_output[$conf->entity];
$triggersendname = 'ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'confirm_createbills') { // Create bills from orders.
$orders = GETPOST('toselect', 'array');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$validate_invoices = GETPOST('validate_invoices', 'int');
$errors = array();
$TFact = array();
$TFactThird = array();
$TFactThirdNbLines = array();
$nb_bills_created = 0;
$lastid= 0;
$lastref = '';
$db->begin();
foreach ($orders as $id_order) {
$cmd = new Commande($db);
if ($cmd->fetch($id_order) <= 0) {
continue;
}
$cmd->fetch_thirdparty();
$objecttmp = new Facture($db);
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
// If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it.
$objecttmp = $TFactThird[$cmd->socid];
} else {
// If we want one invoice per order or if there is no first invoice yet for this thirdparty.
$objecttmp->socid = $cmd->socid;
$objecttmp->thirdparty = $cmd->thirdparty;
$objecttmp->type = $objecttmp::TYPE_STANDARD;
$objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
$objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
$objecttmp->fk_project = $cmd->fk_project;
$objecttmp->multicurrency_code = $cmd->multicurrency_code;
if (empty($createbills_onebythird)) {
$objecttmp->ref_client = $cmd->ref_client;
}
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($datefacture)) {
$datefacture = dol_now();
}
$objecttmp->date = $datefacture;
$objecttmp->origin = 'commande';
$objecttmp->origin_id = $id_order;
$objecttmp->array_options = $cmd->array_options; // Copy extrafields
$res = $objecttmp->create($user);
if ($res > 0) {
$nb_bills_created++;
$lastref = $objecttmp->ref;
$lastid = $objecttmp->id;
$TFactThird[$cmd->socid] = $objecttmp;
$TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
} else {
$langs->load("errors");
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
$error++;
}
}
if ($objecttmp->id > 0) {
$res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
if ($res == 0) {
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
$error++;
}
if (!$error) {
$lines = $cmd->lines;
if (empty($lines) && method_exists($cmd, 'fetch_lines')) {
$cmd->fetch_lines();
$lines = $cmd->lines;
}
$fk_parent_line = 0;
$num = count($lines);
for ($i = 0; $i < $num; $i++) {
$desc = ($lines[$i]->desc ? $lines[$i]->desc : '');
// If we build one invoice for several orders, we must put the ref of order on the invoice line
if (!empty($createbills_onebythird)) {
$desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day'));
}
if ($lines[$i]->subprice < 0) {
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $objecttmp->socid;
$discount->amount_ht = abs($lines[$i]->total_ht);
$discount->amount_tva = abs($lines[$i]->total_tva);
$discount->amount_ttc = abs($lines[$i]->total_ttc);
$discount->tva_tx = $lines[$i]->tva_tx;
$discount->fk_user = $user->id;
$discount->description = $desc;
$discountid = $discount->create($user);
if ($discountid > 0) {
$result = $objecttmp->insert_discount($discountid);
//$result=$discount->link_to_invoice($lineid,$id);
} else {
setEventMessages($discount->error, $discount->errors, 'errors');
$error++;
break;
}
} else {
// Positive line
$product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
// Date start
$date_start = false;
if ($lines[$i]->date_debut_prevue) {
$date_start = $lines[$i]->date_debut_prevue;
}
if ($lines[$i]->date_debut_reel) {
$date_start = $lines[$i]->date_debut_reel;
}
if ($lines[$i]->date_start) {
$date_start = $lines[$i]->date_start;
}
//Date end
$date_end = false;
if ($lines[$i]->date_fin_prevue) {
$date_end = $lines[$i]->date_fin_prevue;
}
if ($lines[$i]->date_fin_reel) {
$date_end = $lines[$i]->date_fin_reel;
}
if ($lines[$i]->date_end) {
$date_end = $lines[$i]->date_end;
}
// Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
// Extrafields
if (method_exists($lines[$i], 'fetch_optionals')) {
$lines[$i]->fetch_optionals();
$array_options = $lines[$i]->array_options;
}
$objecttmp->context['createfromclone'];
$rang = $lines[$i]->rang;
//there may already be rows from previous orders
if (!empty($createbills_onebythird))
$rang = $TFactThirdNbLines[$cmd->socid];
$result = $objecttmp->addline(
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$date_start,
$date_end,
0,
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$product_type,
$rang,
$lines[$i]->special_code,
$objecttmp->origin,
$lines[$i]->rowid,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$lines[$i]->label,
$array_options,
100,
0,
$lines[$i]->fk_unit
);
if ($result > 0) {
$lineid = $result;
if (!empty($createbills_onebythird)) //increment rang to keep order
$TFactThirdNbLines[$rcp->socid]++;
} else {
$lineid = 0;
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
$fk_parent_line = $result;
}
}
}
}
}
//$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
$TFactThird[$cmd->socid] = $objecttmp;
} else {
$TFact[$objecttmp->id] = $objecttmp;
}
}
// Build doc with all invoices
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
$toselect = array();
if (!$error && $validate_invoices) {
$massaction = $action = 'builddoc';
foreach ($TAllFact as &$objecttmp) {
$result = $objecttmp->validate($user);
if ($result <= 0) {
$error++;
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
break;
}
$id = $objecttmp->id; // For builddoc action
// Builddoc
$donotredirect = 1;
$upload_dir = $conf->facture->dir_output;
$permissiontoadd = $user->rights->facture->creer;
// Call action to build doc
$savobject = $object;
$object = $objecttmp;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
$object = $savobject;
}
$massaction = $action = 'confirm_createbills';
}
if (!$error) {
$db->commit();
if ($nb_bills_created == 1) {
$texttoshow = $langs->trans('BillXCreated', '{s1}');
$texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
setEventMessages($texttoshow, null, 'mesgs');
} else {
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
}
// Make a redirect to avoid to bill twice if we make a refresh or back
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($sall) {
$param .= '&sall='.urlencode($sall);
}
if ($socid > 0) {
$param .= '&socid='.urlencode($socid);
}
if ($search_status != '') {
$param .= '&search_status='.urlencode($search_status);
}
if ($search_orderday) {
$param .= '&search_orderday='.urlencode($search_orderday);
}
if ($search_ordermonth) {
$param .= '&search_ordermonth='.urlencode($search_ordermonth);
}
if ($search_orderyear) {
$param .= '&search_orderyear='.urlencode($search_orderyear);
}
if ($search_deliveryday) {
$param .= '&search_deliveryday='.urlencode($search_deliveryday);
}
if ($search_deliverymonth) {
$param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
}
if ($search_deliveryyear) {
$param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_company) {
$param .= '&search_company='.urlencode($search_company);
}
if ($search_ref_customer) {
$param .= '&search_ref_customer='.urlencode($search_ref_customer);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
}
if ($search_total_ht != '') {
$param .= '&search_total_ht='.urlencode($search_total_ht);
}
if ($search_total_vat != '') {
$param .= '&search_total_vat='.urlencode($search_total_vat);
}
if ($search_total_ttc != '') {
$param .= '&search_total_ttc='.urlencode($search_total_ttc);
}
if ($search_project_ref >= 0) {
$param .= "&search_project_ref=".urlencode($search_project_ref);
}
if ($show_files) {
$param .= '&show_files='.urlencode($show_files);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($billed != '') {
$param .= '&billed='.urlencode($billed);
}
header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
exit;
} else {
$db->rollback();
$action = 'create';
$_GET["origin"] = $_POST["origin"];
$_GET["originid"] = $_POST["originid"];
if (!empty($errors)) {
setEventMessages(null, $errors, 'errors');
} else {
setEventMessages("Error", null, 'errors');
}
$error++;
}
}
}
if ($action == 'validate' && $permissiontoadd) {
if (GETPOST('confirm') == 'yes') {
@ -318,7 +665,7 @@ if ($action == 'validate' && $permissiontoadd) {
if ($objecttmp->valid($user, $idwarehouse)) {
setEventMessage($langs->trans('hasBeenValidated', $objecttmp->ref), 'mesgs');
} else {
setEventMessage($langs->trans('CantBeValidated'), 'errors');
setEventMessage($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
}
} else {
@ -345,7 +692,7 @@ if ($action == 'shipped' && $permissiontoadd) {
$error = 0;
foreach ($toselect as $checked) {
if ($objecttmp->fetch($checked)) {
if ($objecttmp->statut == 1) {
if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
if ($objecttmp->cloture($user)) {
setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs');
} else {
@ -441,7 +788,7 @@ $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture
$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
$sql .= ' c.fk_input_reason';
$sql .= ' c.fk_input_reason, c.import_key';
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
}
@ -974,7 +1321,7 @@ if ($resql) {
$moreforfilter = '';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@ -1275,6 +1622,11 @@ if ($resql) {
print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
print '</td>';
}
// Import key
if (!empty($arrayfields['c.import_key']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print '</td>';
}
// Status
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone center">';
@ -1436,6 +1788,9 @@ if ($resql) {
if (!empty($arrayfields['c.facture']['checked'])) {
print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['c.import_key']['checked'])) {
print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
}
@ -1935,8 +2290,8 @@ if ($resql) {
// Note public
if (!empty($arrayfields['c.note_public']['checked'])) {
print '<td align="center" class="nowrap">';
print dol_escape_htmltag($obj->note_public);
print '<td class="center">';
print dol_string_nohtmltag($obj->note_public);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -1945,8 +2300,8 @@ if ($resql) {
// Note private
if (!empty($arrayfields['c.note_private']['checked'])) {
print '<td align="center" class="nowrap">';
print dol_escape_htmltag($obj->note_private);
print '<td class="center">';
print dol_string_nohtmltag($obj->note_private);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2063,6 +2418,13 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
// Import key
if (!empty($arrayfields['c.import_key']['checked'])) {
print '<td class="nowrap center">'.$obj->import_key.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Status
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';

View File

@ -45,8 +45,14 @@ if ($mode == 'customer' && !$user->rights->commande->lire) {
if ($mode == 'supplier' && empty($user->rights->fournisseur->commande->lire)) {
accessforbidden();
}
if ($mode == 'supplier') {
$object_status = GETPOST('object_status', 'array:int');
$object_status = implode(',', $object_status);
} else {
$object_status = GETPOST('object_status', 'intcomma');
}
$object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int');
$categ_id = GETPOST('categ_id', 'categ_id');

View File

@ -19,11 +19,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/accounting-files.php
* \ingroup compta
* \brief Page to show portoflio and files of a thirdparty and download it
*/
/**
* \file htdocs/compta/accounting-files.php
* \ingroup compta
* \brief Page to show portoflio and files of a thirdparty and download it
*/
if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
if (!defined('NOTOKENRENEWAL')) {
@ -588,14 +588,13 @@ foreach ($listofchoices as $choice => $val) {
print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.$disabled.'> <label for="'.$choice.'">'.$langs->trans($val['label']).'</label></div>';
}
print '<input type="submit" class="button" name="search" value="'.$langs->trans("Search").'">';
print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">';
print '</form>'."\n";
print dol_get_fiche_end();
if (!empty($date_start) && !empty($date_stop)) {
$param = 'action=searchfiles';
$param .= '&date_startday='.GETPOST('date_startday', 'int');
$param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
$param .= '&date_startyear='.GETPOST('date_startyear', 'int');
@ -603,13 +602,30 @@ if (!empty($date_start) && !empty($date_stop)) {
$param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
$param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
foreach ($listofchoices as $choice => $val) {
$param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0);
if (GETPOST($choice, 'int')) {
$param .= '&'.$choice.'=1';
}
}
print '<form name="dl" action="'.$_SERVER["PHP_SELF"].'?action=dl" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.currentToken().'">';
$TData = dol_sort_array($filesarray, $sortfield, $sortorder);
$filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel');
print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.newToken().'&output=file&file='.urlencode($filename).$param.'"';
if (empty($TData)) {
print " disabled";
}
print '>'."\n";
print $langs->trans("Download");
print '</a><br>';
$param .= '&action=searchfiles';
/*
print '<input type="hidden" name="token" value="'.currentToken().'">';
print '<input type="hidden" name="date_startday" value="'.GETPOST('date_startday', 'int').'" />';
print '<input type="hidden" name="date_startmonth" value="'.GETPOST('date_startmonth', 'int').'" />';
print '<input type="hidden" name="date_startyear" value="'.GETPOST('date_startyear', 'int').'" />';
@ -620,8 +636,13 @@ if (!empty($date_start) && !empty($date_stop)) {
print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
}
print '<input class="butAction butDownload" type="submit" value="'.$langs->trans("Download").'" />';
print '<input class="butAction butDownload small marginleftonly" type="submit" value="'.$langs->trans("Download").'"';
if (empty($TData)) {
print " disabled";
}
print '/>';
print '</form>'."\n";
*/
print '<br>';
@ -645,172 +666,181 @@ if (!empty($date_start) && !empty($date_stop)) {
print '<td class="center">'.$langs->trans("Currency").'</td>';
}
print '</tr>';
if ($result) {
$TData = dol_sort_array($filesarray, $sortfield, $sortorder);
if (empty($TData)) {
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
if (empty($TData)) {
print '<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print '</tr>';
} else {
// Sort array by date ASC to calculate balance
$totalET_debit = 0;
$totalIT_debit = 0;
$totalVAT_debit = 0;
$totalET_credit = 0;
$totalIT_credit = 0;
$totalVAT_credit = 0;
// Display array
foreach ($TData as $data) {
$html_class = '';
//if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
//elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
print '<tr class="oddeven '.$html_class.'">';
// Type
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data['item'])).'">'.$langs->trans($data['item']).'</td>';
// Date
print '<td class="center">';
print dol_print_date($data['date'], 'day');
print "</td>\n";
// Date due
print '<td class="center">';
print dol_print_date($data['date_due'], 'day');
print "</td>\n";
// Ref
print '<td class="nowraponall tdoverflowmax150">';
if ($data['item'] == 'Invoice') {
$invoice->id = $data['id'];
$invoice->ref = $data['ref'];
$invoice->total_ht = $data['amount_ht'];
$invoice->total_ttc = $data['amount_ttc'];
$invoice->total_tva = $data['amount_vat'];
$invoice->multicurrency_code = $data['currency'];
print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'SupplierInvoice') {
$supplier_invoice->id = $data['id'];
$supplier_invoice->ref = $data['ref'];
$supplier_invoice->total_ht = $data['amount_ht'];
$supplier_invoice->total_ttc = $data['amount_ttc'];
$supplier_invoice->total_tva = $data['amount_vat'];
$supplier_invoice->multicurrency_code = $data['currency'];
print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'ExpenseReport') {
$expensereport->id = $data['id'];
$expensereport->ref = $data['ref'];
print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
} elseif ($data['item'] == 'SalaryPayment') {
$salary_payment->id = $data['id'];
$salary_payment->ref = $data['ref'];
print $salary_payment->getNomUrl(1);
} elseif ($data['item'] == 'Donation') {
$don->id = $data['id'];
$don->ref = $data['ref'];
print $don->getNomUrl(1, 0, '', 0);
} elseif ($data['item'] == 'SocialContributions') {
$charge_sociales->id = $data['id'];
$charge_sociales->ref = $data['ref'];
print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
} elseif ($data['item'] == 'VariousPayment') {
$various_payment->id = $data['id'];
$various_payment->ref = $data['ref'];
print $various_payment->getNomUrl(1, '', 0, 0);
} elseif ($data['item'] == 'LoanPayment') {
$payment_loan->id = $data['id'];
$payment_loan->ref = $data['ref'];
print $payment_loan->getNomUrl(1, 0, 0, '', 0);
} else {
print $data['ref'];
}
print '</tr>';
} else {
// Sort array by date ASC to calculate balance
print '</td>';
$totalET_debit = 0;
$totalIT_debit = 0;
$totalVAT_debit = 0;
$totalET_credit = 0;
$totalIT_credit = 0;
$totalVAT_credit = 0;
// Display array
foreach ($TData as $data) {
$html_class = '';
//if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
//elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
print '<tr class="oddeven '.$html_class.'">';
// Type
print '<td>'.$langs->trans($data['item']).'</td>';
// Date
print '<td class="center">';
print dol_print_date($data['date'], 'day');
print "</td>\n";
// Date due
print '<td class="center">';
print dol_print_date($data['date_due'], 'day');
print "</td>\n";
// Ref
print '<td class="nowraponall">';
if ($data['item'] == 'Invoice') {
$invoice->id = $data['id'];
$invoice->ref = $data['ref'];
$invoice->total_ht = $data['amount_ht'];
$invoice->total_ttc = $data['amount_ttc'];
$invoice->total_tva = $data['amount_vat'];
$invoice->multicurrency_code = $data['currency'];
print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'SupplierInvoice') {
$supplier_invoice->id = $data['id'];
$supplier_invoice->ref = $data['ref'];
$supplier_invoice->total_ht = $data['amount_ht'];
$supplier_invoice->total_ttc = $data['amount_ttc'];
$supplier_invoice->total_tva = $data['amount_vat'];
$supplier_invoice->multicurrency_code = $data['currency'];
print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'ExpenseReport') {
$expensereport->id = $data['id'];
$expensereport->ref = $data['ref'];
print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
} elseif ($data['item'] == 'SalaryPayment') {
$salary_payment->id = $data['id'];
$salary_payment->ref = $data['ref'];
print $salary_payment->getNomUrl(1);
} elseif ($data['item'] == 'Donation') {
$don->id = $data['id'];
$don->ref = $data['ref'];
print $don->getNomUrl(1, 0, '', 0);
} elseif ($data['item'] == 'SocialContributions') {
$charge_sociales->id = $data['id'];
$charge_sociales->ref = $data['ref'];
print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
} elseif ($data['item'] == 'VariousPayment') {
$various_payment->id = $data['id'];
$various_payment->ref = $data['ref'];
print $various_payment->getNomUrl(1, '', 0, 0);
} elseif ($data['item'] == 'LoanPayment') {
$payment_loan->id = $data['id'];
$payment_loan->ref = $data['ref'];
print $payment_loan->getNomUrl(1, 0, 0, '', 0);
} else {
print $data['ref'];
}
print '</td>';
// File link
print '<td>';
if (!empty($data['files'])) {
foreach ($data['files'] as $id => $filecursor) {
print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank" rel="noopener noreferrer">'.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).'</a>&nbsp;'.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'<br>';
// File link
print '<td class="tdoverflowmax150">';
if (!empty($data['files'])) {
foreach ($data['files'] as $id => $filecursor) {
$tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0);
if ($tmppreview) {
print $tmppreview;
}
$filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']);
print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank" rel="noopener noreferrer" title="'.dol_escape_htmltag($filename).'">';
if (empty($tmppreview)) {
print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright');
}
print $filename;
print '</a><br>';
}
print "</td>\n";
}
print "</td>\n";
// Paid
print '<td aling="left">'.$data['paid'].'</td>';
// Paid
print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>';
// Total ET
print '<td align="right">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</td>\n";
// Total IT
print '<td align="right">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."</td>\n";
// Total VAT
print '<td align="right">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</td>\n";
// Total ET
print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n";
// Total IT
print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."</span></td>\n";
// Total VAT
print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n";
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n";
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n";
print '<td class="center">'.$data['thirdparty_code']."</td>\n";
print '<td class="center">'.$data['thirdparty_code']."</td>\n";
print '<td class="center">'.$data['country_code']."</td>\n";
print '<td class="center">'.$data['country_code']."</td>\n";
print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n";
// VAT number
print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n";
if ($data['sens']) {
$totalET_credit += $data['amount_ht'];
$totalIT_credit += $data['amount_ttc'];
$totalVAT_credit += $data['amount_vat'];
} else {
$totalET_debit -= $data['amount_ht'];
$totalIT_debit -= $data['amount_ttc'];
$totalVAT_debit -= $data['amount_vat'];
}
if (!empty($conf->multicurrency->enabled)) {
print '<td class="center">'.$data['currency']."</td>\n";
}
print "</tr>\n";
if ($data['sens']) {
$totalET_credit += $data['amount_ht'];
$totalIT_credit += $data['amount_ttc'];
$totalVAT_credit += $data['amount_vat'];
} else {
$totalET_debit -= $data['amount_ht'];
$totalIT_debit -= $data['amount_ttc'];
$totalVAT_debit -= $data['amount_vat'];
}
// Total credits
print '<tr class="liste_total">';
print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>';
print '<td align="right">'.price(price2num($totalET_credit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>';
print '<td colspan="4"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n";
// Total debits
print '<tr class="liste_total">';
print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>';
print '<td align="right">'.price(price2num($totalET_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>';
print '<td colspan="4"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n";
// Balance
print '<tr class="liste_total">';
print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>';
print '<td align="right">'.price(price2num($totalET_credit + $totalET_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>';
print '<td colspan="4"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
print '<td class="center">'.$data['currency']."</td>\n";
}
print "</tr>\n";
}
// Total credits
print '<tr class="liste_total">';
print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>';
print '<td align="right">'.price(price2num($totalET_credit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>';
print '<td colspan="4"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n";
// Total debits
print '<tr class="liste_total">';
print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>';
print '<td align="right">'.price(price2num($totalET_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>';
print '<td colspan="4"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n";
// Balance
print '<tr class="liste_total">';
print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>';
print '<td align="right">'.price(price2num($totalET_credit + $totalET_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>';
print '<td colspan="4"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n";
}
print "</table>";
print '</div>';
}

View File

@ -214,7 +214,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_thirdparty_user = '';
$search_num_releve = '';
$search_conciliated = '';
$toselect = '';
$toselect = array();
$search_account = "";
if ($id > 0 || !empty($ref)) {
@ -276,6 +276,9 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', '
if ($offset) {
$param .= '&offset='.urlencode($offset);
}
if ($limit) {
$param .= '&limit='.urlencode($limit);
}
if ($search_conciliated != '' && $search_conciliated != '-1') {
$param .= '&search_conciliated='.urlencode($search_conciliated);
}
@ -980,21 +983,27 @@ if ($resql) {
$moreforfilter = '';
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateOperationShort').' ';
$moreforfilter .= $langs->trans('DateOperationShort');
$moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'</div>';
//$moreforfilter .= ' - ';
$moreforfilter .= '<div class="nowrap inline-block">'.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')).'</div>';
$moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
$moreforfilter .= '</div>';
$moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
$moreforfilter .= '</div>';
$moreforfilter .= '</div>';
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateValueShort').' ';
$moreforfilter .= $langs->trans('DateValueShort');
$moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'</div>';
//$moreforfilter .= ' - ';
$moreforfilter .= '<div class="nowrap inline-block">'.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')).'</div>';
$moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
$moreforfilter .= '</div>';
$moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
$moreforfilter .= '</div>';
$moreforfilter .= '</div>';
if (!empty($conf->categorie->enabled)) {

View File

@ -65,7 +65,8 @@ $hookmanager->initHooks(array('bankcard', 'globalcard'));
// Security check
$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid';
$fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref';
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
@ -724,7 +725,7 @@ if ($action == 'create') {
print '</table>';
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) {
print '<div class="underbanner clearboth"></div>';
//print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';
@ -777,13 +778,14 @@ if ($action == 'create') {
print '</td></tr>';
if ($conf->prelevement->enabled) {
print '<tr><td>'.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')</td>';
print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
print '<td>'.$object->ics.'</td>';
print '</tr>';
}
// TODO ICS is not used with bank transfer !
if ($conf->paymentbybanktransfer->enabled) {
print '<tr><td>'.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')</td>';
print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
print '<td>'.$object->ics_transfer.'</td>';
print '</tr>';
@ -1081,12 +1083,12 @@ if ($action == 'create') {
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alphanohtml') : $object->bic).'"></td></tr>';
if ($conf->prelevement->enabled) {
print '<tr><td>'.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')</td>';
print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.(GETPOSTISSET('ics') ? GETPOST('ics', 'alphanohtml') : $object->ics).'"></td></tr>';
}
if ($conf->paymentbybanktransfer->enabled) {
print '<tr><td>'.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')</td>';
print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics_transfer" value="'.(GETPOSTISSET('ics_transfer') ? GETPOST('ics_transfer', 'alphanohtml') : $object->ics_transfer).'"></td></tr>';
print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td>';

View File

@ -519,9 +519,10 @@ class Account extends CommonObject
* @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on.
* @param int $datev Date value
* @param string $num_releve Label of bank receipt for reconciliation
* @param float $amount_main_currency Amount
* @return int Rowid of added entry, <0 if KO
*/
public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '')
public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '', $amount_main_currency = null)
{
// Deprecation warning
if (is_numeric($oper)) {
@ -579,6 +580,7 @@ class Account extends CommonObject
$accline->datev = $datev;
$accline->label = $label;
$accline->amount = $amount;
$accline->amount_main_currency = $amount_main_currency;
$accline->fk_user_author = $user->id;
$accline->fk_account = $this->id;
$accline->fk_type = $oper;
@ -866,7 +868,7 @@ class Account extends CommonObject
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('BANKACCOUNT_UPDATE', $user);
$result = $this->call_trigger('BANKACCOUNT_MODIFY', $user);
if ($result < 0) {
$error++;
}
@ -1453,9 +1455,13 @@ class Account extends CommonObject
// Call function to check BAN
if (!checkIbanForAccount($this) || !checkSwiftForAccount($this)) {
if (!checkIbanForAccount($this)) {
$this->error_number = 12;
$this->error_message = 'IBANSWIFTControlError';
$this->error_message = 'IBANNotValid';
}
if (!checkSwiftForAccount($this)) {
$this->error_number = 12;
$this->error_message = 'SwiftNotValid';
}
/*if (! checkBanForAccount($this))
{
@ -1728,7 +1734,7 @@ class Account extends CommonObject
if ($dbs->query($sql)) {
return true;
} else {
//if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B.
//if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B.
//$this->errors = $dbs->lasterror();
return false;
}
@ -1797,7 +1803,8 @@ class AccountLine extends CommonObject
*/
public $datev;
public $amount;
public $amount; /* Amount of payment in the bank account currency */
public $amount_main_currency; /* Amount in the currency of company if bank account use another currency */
/**
* @var int ID
@ -1958,6 +1965,7 @@ class AccountLine extends CommonObject
$sql .= ", datev";
$sql .= ", label";
$sql .= ", amount";
$sql .= ", amount_main_currency";
$sql .= ", fk_user_author";
$sql .= ", num_chq";
$sql .= ", fk_account";
@ -1972,7 +1980,8 @@ class AccountLine extends CommonObject
$sql .= ", '".$this->db->idate($this->datev)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", ".price2num($this->amount);
$sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null");
$sql .= ", ".(empty($this->amount_main_currency) ? "NULL" : price2num($this->amount_main_currency));
$sql .= ", ".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) : "null");
$sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null");
$sql .= ", '".$this->db->escape($this->fk_account)."'";
$sql .= ", '".$this->db->escape($this->fk_type)."'";

View File

@ -587,10 +587,14 @@ foreach ($accounts as $key => $type) {
// Accountancy journal
if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
print '<td>';
if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) {
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($objecttmp->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
if (!empty($conf->accounting->enabled)) {
if (empty($objecttmp->fk_accountancy_journal)) {
print img_warning($langs->trans("Mandatory"));
} else {
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($objecttmp->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
}
} else {
print '';
}

View File

@ -179,7 +179,7 @@ if (empty($reshook)) {
$action = 'create';
}
if ($action == 'delete') {
if ($action == 'confirm_delete' && $confirm == 'yes') {
$result = $object->fetch($id);
if ($object->rappro == 0) {
@ -543,6 +543,12 @@ if ($id) {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350);
}
// Confirmation of the removal of the Various Payment
if ($action == 'delete') {
$text = $langs->trans('ConfirmDeleteVariousPayment');
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2);
}
print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
$morehtmlref = '<div class="refidno">';

View File

@ -165,7 +165,7 @@ if (empty($reshook)) {
$search[$key.'_dtend'] = '';
}
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

View File

@ -641,7 +641,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
if ($result > 0) {
// Define output language and generate document
@ -967,7 +967,7 @@ if ($action == 'create') {
// Title
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>';
print '<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'">';
print '<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'" autofocus>';
print '</td></tr>';
// Third party
@ -1034,21 +1034,11 @@ if ($action == 'create') {
// Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
print img_picto('', 'payment', 'class="pictofixedwidth"');
print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
//$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1);
print "</td></tr>";
// Project
if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
print img_picto('', 'project');
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
print '</td></tr>';
}
// Bank account
if ($object->fk_account > 0) {
print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
@ -1056,10 +1046,22 @@ if ($action == 'create') {
print "</td></tr>";
}
// Project
if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
print img_picto('', 'project', 'class="pictofixedwidth"');
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
print '</td></tr>';
}
// Model pdf
print "<tr><td>".$langs->trans('Model')."</td><td>";
include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
$list = ModelePDFFactures::liste_modeles($db);
print img_picto('', 'generic', 'class="pictofixedwidth"');
print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
print "</td></tr>";
@ -1605,19 +1607,19 @@ if ($action == 'create') {
// Lines
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'">
';
print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">';
print '<input type="hidden" name="token" value="' . newToken().'">';
print '<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">';
print '<input type="hidden" name="mode" value="">';
print '<input type="hidden" name="id" value="' . $object->id.'">';
print '<input type="hidden" name="page_y" value="">';
if (!empty($conf->use_javascript_ajax) && $object->statut == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">';
print '<table id="tablelines" class="noborder noshadow centpercent">';
// Show object lines
if (!empty($object->lines)) {
$canchangeproduct = 1;

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