Merge branch 'Dolibarr:develop' into new-resource-full-address

This commit is contained in:
William Mead 2023-11-14 09:39:36 +01:00 committed by GitHub
commit a39255a8fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
513 changed files with 19077 additions and 12003 deletions

View file

@ -18,7 +18,7 @@ Default **language here is english**. So please prepare your contributions in en
<a name="code"></a>Code
<a name="code"></a>Submit code
---------------------
### Basic workflow
@ -35,12 +35,14 @@ Default **language here is english**. So please prepare your contributions in en
Unless you're fixing a bug, all pull requests should be made against the *develop* branch.
If you're fixing a bug, it is preferred that you cook your fix and pull request it
against the oldest version affected that's still supported.
If you're fixing a bug, it is preferred that you cook your fix and pull request it against an oldest version affected.
We officially support versions N, N − 1 and N − 2 for N the latest version available.
We recommend to push it into N - 2 for N the latest version available, if not possible into version N - 1, and finally into develop.
This is just a recommendation, currently, if you push a bug fix on a very old version, it is still merged and propagated into
higher versions.
Choose your base branch accordingly.
The rule N - 2 is just a tip if you don't know which version to choose to get the best the best compromise between ease of correction
and number of potential beneficiaries of the correction.
### General rules
Please don't edit the ChangeLog file. File will be generated from all commit messages during release process by the project manager.
@ -72,7 +74,7 @@ The keyword can be ommitted if your commit does not fit in any of the following
- Close/CLOSE: for closing a referenced feature request
- New/NEW: for an unreferenced new feature (Opening a feature request and using close is prefered)
- Perf/PERF: for performance enhancement
- Qual/QUAL: for quality code enhancement or re-engeneering
- Qual/QUAL: for quality code enhancement or re-engineering
#### Issuenum
If your commit fixes a referenced bug or feature request.
@ -93,7 +95,7 @@ Feel free to express technical details, use cases or anything relevant to the cu
This section can span multiple lines.
Try to keep lines under 120 characters.
If your PR is a change on interface, you must also paste a screenshot showing the new screen.
#### Examples
<pre>
@ -105,7 +107,7 @@ NEW|New|QUAL|Qual|PERF|Perf Short description (In upper case to appear into Chan
or
Short description (when the commit is not introducing feature nor closing a bug)
Long description (Can span accross multiple lines).
Long description (Can span across multiple lines).
</pre>
### Pull Requests
@ -133,7 +135,8 @@ If your PR has errors reported by the Continuous Integration Platform, it means
If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet.
In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag ask you. The majority of open PR are waiting an action of the author of the PR.
Statistics on Dolibarr project shows that 95% of submitted PR are reviewed and tagged. Average answer delay is also one of the best among Open source projects (just few days before having the Answer Tag set). This is one of the most important ratio of answered PR in Open Source world for a major project. Don't expect the core team to reach the 100%. A so high ratio is very rare on a so popular project and with the increasing popularity of Dolibarr, this ratio will probably decrease in future to a more common level.
Statistics on Dolibarr project shows that 95% of submitted PR are reviewed and tagged. Average answer delay is also one of the best among Open source projects (just few days before having the Answer Tag set). This is one of the most important ratio of answered PR in Open Source world for a major project. Don't expect the core team to reach the 100%.
A so high ratio is very rare on a so popular project and with the increasing popularity of Dolibarr, this ratio will probably decrease in future to a more common level.
### Resources

View file

@ -200,12 +200,6 @@ source_file = htdocs/langs/en_US/ldap.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[o:dolibarr-association:p:dolibarr:r:link]
file_filter = htdocs/langs/<lang>/link.lang
source_file = htdocs/langs/en_US/link.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[o:dolibarr-association:p:dolibarr:r:loan]
file_filter = htdocs/langs/<lang>/loan.lang
source_file = htdocs/langs/en_US/loan.lang

260
ChangeLog
View file

@ -7,8 +7,172 @@ English Dolibarr ChangeLog
For users:
----------
NEW: Compatibility with PHP 8.2
NEW: Add a confirmation popup when deleting extrafields
NEW: Close #20930 Use ajax for state loading after country change
NEW: #23331 Add support for parent projects (#24856)
NEW: #22531 Expense report - Add two fields into export : Qty & Unit price (excl.) (#26309)
NEW: #22626 date filter thirdparties contracts projects (#22707)
NEW: #24085 Add the Project filter
NEW: #25312 Support extrafields in selectForForms
NEW: #26312 Manage intermediate BIC - SQL Part (#26325)
NEW: Accountancy - Add quick navigation with keyboard shortcut on ledger (#26221)
NEW: Accountancy - FEC/FEC2 format export with attachments (#26192)
NEW: Accountancy - Option to choose length of lettering code
NEW: Add a button to create a product or a service from an order or an invoice (#26173)
NEW: Add a button to re-encrypt data of a dolcrypt extrafield password
NEW: Add a CLI tool to regenerate all documents
NEW: Add a goto url from smartphone search page
NEW: Add all id prof checker on thirdparty for code compta customer and supplier
NEW: add and list external contributors on ticket public interface
NEW: Add a protection on purgeFiles
NEW: Add a public page to list all open surveys
NEW: Add chart of accounts PCG08-PYME-CAT for ES in catalan language
NEW: add constant to check if qty shipped not greater than qty ordered
NEW: Add context for the movement stock (role toconsume/toproduce) on mrp
NEW: Add contract link on ticket
NEW: Add culum Technical ID in list of details lines of an order (#26164)
NEW: ADD: custom compute for exports
NEW: Add custom Text on footer total (#26334)
NEW: Add different picto for each type of extrafields (date, string, ...)
NEW: Add edit line on MO (#26122)
NEW: Added notification on closed intervention
NEW: Added of a popup on validation instead of a database fielld to know if the user wants to include subwarehouse
NEW: Added of the field "include_sub_warehouse" in the table "llx_inventory"
NEW: Added total line to third-parties list (#26148)
NEW: Added VAT free & VAT amounts on payment input
NEW: Add ext payment system ID in the payment page with link to Stripe
NEW: Add field TechnicalID in list of users
NEW: Add filter on status of line of a dictionary
NEW: Add get_substitutionarray_other() on shipping odt (#25080)
NEW: add IdProfCheck on thirdparty for BE (xxxx.xxx.xxx)
NEW: Add index on prelevement_demande
NEW: Add invoice subtype in customer invoice (#26543) and template invoice (SQL part) (#26535)
NEW: Add label to price level when changing price (#26240)
NEW: Add modifications of template invoices into agenda
NEW: Add more company informations (ProfId7 to 10) (#25266)
NEW: Add more information to holiday mailings (#25461)
NEW: Add more param on fetch() to prepare perf optimization
NEW: Add more tables activated by module activation only
NEW: Add new field into $fields array + Creation of the function getChildWarehouse()
NEW: Add option for cancel consumed and produced lines (delete lines and rollback stocks) when delete or cancel an manufacturing order (#26254)
NEW: Add option in PDF for purchase order and quotation to hide prices
NEW: Add option TAKEPOS_HIDE_PRODUCT_PRICES to hide prices in TakePOS
NEW: add order supplier submit notif
NEW: add parent product column on list
NEW: Add picto in product/service list in object lines (#25511)
NEW: Add possibility to choose separator #21426
NEW: Add preselected update keys attribute to import class and select it by default if filled
NEW: add product barcode on stock exports
NEW: Add recurring behaviour
NEW: add recursive deletion option for child m os (#26102)
NEW: Add refactoring user permission (#26162)
NEW: add sorting of product price list by customer (#26483)
NEW: Add tab Events/Agenda on recurring invoices
NEW: Add the formEditObjectLine hook on commande card and invoice card
NEW: Add the picto phone of thirdparty on the kanban view of projects
NEW: Add the status of partnership to select partnership for emailing
NEW: add Ticket tab on contract
NEW: agenda per user use quarter hour split instead of half hour split
NEW: Allow generation of delivery note through REST-API (#26226)
NEW: Allow sync of currency rates with currency layer by default.
NEW: Allow to have products not managed in stocks - SQL Part (#26190)
NEW: Assign contact to a ticket message (#24735)
NEW: Better protection against reserved words
NEW: billing on shipment+reception. Can be done before or after delivery.
NEW: can edit bomline workstation
NEW: Can edit both the Test and Live stripe customer account on payment
NEW: Can include product variants in list of products
NEW: Can manage ODT documents for groups of users.
NEW: Can modify the picto into modulebuilder
NEW: Can restore product in stock when deleting the supplier invoice
NEW: Can see the favicon file into setup of properties of a website
NEW: Can switch product batch management to no management. (#21691)
NEW: Can upload/delete ODT template for project and tasks
NEW: chart of accounts ES PCG08-PYME-CAT in catalan language
NEW: clone skill object (#26526)
NEW: close notification for interventions
NEW: column in table prelevement_lignes for fk_user (#26196)
NEW: CONF allow modify ticket classification even if closed
NEW: conf to display date entry stock exped and sort in date order (#22625)
NEW: create a product from a free line in a document (#22324)
NEW: customize position in complete_head_from_modules (#26406)
NEW: Date d'entree en stock sur les exped au moment de la création
NEW: Date field for shipment export (#25574)
NEW: Date format dayhoursec is using year on 2 char on smartphones
NEW: Default customer, category and product when enable TakePOS (#25031)
NEW: Disable not used PHP streams
NEW: do not add default value in list
NEW: drop down for action button show a simple button if only 1 action
NEW: Enhance github_commits_perversion to get more stats on git commits
NEW: Enhance IPN to support payment_intent.succeeded for both card/ban
NEW: extrafields password accepts 'dolcrypt' algorithm (reversible algo)
NEW: Factorize a lot of code for numbering modules
NEW: filter on from/to period rather than month/year (#26378)
NEW: FontAwesome - Add possibility to select another version
NEW: Form for add object's property on moduleBuilder
NEW: Can generate SEPA files for salaries (#26541)
NEW: massactions to delete projects
NEW: Generic doc template for donations (#26338)
NEW: Get list evaluation with skills details in user fiche (#26510)
NEW: hidden conf to disable use of dns_get_record (which can become unresponsive) (#26339)
NEW: improved resource data structure
NEW: Include sub warehouse in inventory
NEW: inventory without virtual products (kits)
NEW: Invoice subtypes for customers and vendors (#26233)
NEW: Invoice time from task, make task note better display in invoice line
NEW: lazy load to substitute project variables (#26451)
NEW: LDAP Active Directory UserAccountControl (#25507)
NEW: Library including math and financial functions (#25035)
NEW: Loan - Can upload a file with drag and drop
NEW: Manage rate indirect. (#26449)
NEW: memorize model name for pdf hooks
NEW: Menu editor is reponsive
NEW: Merge the "Create ..." buttons on contract into one.
NEW: More accurate tooltip on what admin permissions are
NEW: (#24834) new option for hide the footer (#25464)
NEW: (#25044) new option for choose project visibility
NEW: new option for hide the footer of tickets on the public interface
NEW: no need to create invoice supplier object on supplier card for standalone credit note
NEW: Option to show label, ref+label or only ref of product in TakePOS
NEW: payment full amount detail tooltip
NEW: possibility to deselect line when create a recurring invoice + missing to use fk_parent_line
NEW: Project - List - use select2 multiselect for status
NEW: Propagate invoice extrafields into template invoice (#26529)
NEW: remove include_subwarehouse form llx_inventory database table
NEW: resource improvements - data structure (#26285)
NEW: Retrieve vat details from the Greek Ministry of Finance GSIS SOAP web service and autocomplete third party fields
NEW: Right for stats orders (#24607)
NEW: rights and check access to create portal accounts
NEW: Row in list higher height (#26177)
NEW: Save date of RUM creation when creating a Stripe SEPA mandate
NEW: shipment can include service (for information and invoicing) (#26407)
NEW: Show id of module on the tooltip module help page
NEW: show VAT free amount on payment input close #26208 (#26209)
NEW: start and end date for due date filter on invoice list
NEW: Sub total in list (#26165)
NEW: Suport html content for combo list of email recipient
NEW: Website: Support of js into the Dolibarr server preview
NEW: TakePOS - add constant to check qty asked is available (#24820)
NEW: TakePOS - add constant to choose contact instead of customer (#24807)
NEW: TakePOS - amount label with or without tax in free product (#24829)
NEW: TakePOS compatibility with lots and serials
NEW: TakePOS compatibility with lots and serials (#26426)
NEW: Tooltips are using ajax by default
NEW: Top menu support picto of modules that are font awesome picto.
NEW: updating by adding massactions for delete projects in societe tab
NEW: updating by adding tooltip for api section in Modulebuilder
NEW: updating by adjust request Sql for Salary invoice (#26279)
NEW: updating for display Help title when try to delete Don (issue #25314)
NEW: Upgrade in module builder in menu section
NEW: use account address in sepa mandate (#23642)
NEW: VAT rate - Add entity
NEW: webportal site account
NEW: When an user unset the batch management of products, transformation of each batch stock mouvement in global stock mouvement
SEC: #25512 applicative anti bruteforce - security on too many login attempts (#25520)
SEC: Add action confirm_... as sensitive to need a CSRF token
...
For developers or integrators:
------------------------------
@ -16,24 +180,110 @@ For developers or integrators:
QUAL Reduce very seriously the technical debt (using PHPStan, Psalm and Rector)
NEW Tool in dev/tools/rector to autofix code using style coding practice rules
PERF: Removed a useless fetch_thirdparty
PERF: Perf avoid 2 useless fetch into the triggers of agenda.
PERF: performance & code quality enhancements template sections
QUAL: Remove hardcoded code for OVH sms. Generic method is ok now.
QUAL: Code fix using rector
QUAL: Force subclass MINVERSION (#26314)
QUAL: group all flag images into 1 sprite file. (#26459)
QUAL: Move conf->global into getDolGlobal...
QUAL: Refactor merging companies and fix #26272 with Reception objects (#26320)
QUAL: Removed deprecated field remise, remise_percent, remise_absolute
QUAL: Standardize code and look and feel for dictionaries
QUAL: Standardize code. Renamed ID of user properties into ->user_xxx_id
QUAL: Use dol_clone with parameter 2 for ->oldcopy
QUAL: use switch case instead of if elseif statements for actions
NEW: [Add hook in user bank page]
NEW: #19501 Add two hooks in dolreceiptprinter.php (#26439)
NEW: Accountancy - Add hooks on PrintFieldList for expensereportsjournal, purchasesjournal, sellsjournal
NEW: add a $notrigger param to Product::updatePrice() method (#26404)
NEW: Add a rule to fix empty($conf->global->...) into !getDolGlobal...
NEW: Add column extraparams on societe_rib
NEW: Add hook on selectLotDataList() function (#25368)
NEW: add Hooks and prepare extrafields management for product invoices consumptions (#26280)
NEW: Add hooks on import, step 5 - 6 (#24915)
NEW: add hook tabContentCreateSupplierOrder (#26418)
NEW: add hook tabContentViewSupplierInvoice (#26431)
NEW: add new hook AfterImportInsert
NEW: add new hook OrderCard (#26380)
NEW: add new hook tabContentCreateOrder (#26408)
NEW: Add phpunit for REST API of contacts
NEW: Add triggers COMPANY_RIB_XXX already present in companybankaccount.class.php
NEW: Add triggers on import success
NEW: Add trigger when deleting a bank account line
NEW: subproduct triggers in product class (#25142)
NEW: ModuleBuilder: add section changeLog to Doc in MB
NEW: ModuleBuilder: Add api url to documentation in ModuleBuilder
NEW: ModuleBuilder: Checkin comments begin and end before each actions
NEW: ModuleBuilder: edit properties in description tab for ModuleBuilder
NEW: ModuleBuilder: remove dictionary in ModuleBuilder
NEW: ModuleBuilder: add page for create dictionary
NEW: ModuleBuilder: add badge for each tabs
NEW: ModuleBuilder: for edit name of dictionnary and delete it in MB
NEW: add barcode function to check if EAN13 is valid (
WARNING:
--------
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
The following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The property ->brouillon has been removed from all classes. It was not reliable and was a duplicate of ->status == self::STATUS_DRAFT.
* The duplicated and deprecated property ->date_livraison that was renamed into ->delivery_date has been completely removed.
* The property ->user_close to store ID of closing user has been renamed into ->user_closing_id.
* The property ->user_validation to store ID of user validating has been renamed into ->user_validation_id.
* The property ->user_creation to store ID of user of creation has been renamed into ->user_creation_id.
* The property ->user_modification to store ID of user of modification has been renamed into ->user_modification_id.
* The duplicate property ->user_creat, ->date_creat, ->date_valid has been removed
* The duplicate property ->user_creat, ->date_creat, ->date_valid has been removed (use instead user_creation, date_creation, date_validation).
* The method get_substitutionarray_shipment_lines() has been removed. Use the generic get_substitutionarray_lines() instead.
* The method ProductcustomerPrice->fetch_all_log() has been renamed into camel case ->fetchAllLog()
* Recheck setup of your module workflow to see if you need to enable the new setting to have shipment set to billed automatically when
* Recheck the setup of your module Workflow to see if you need to enable the new setting to have shipment set to billed automatically when
an invoice from a shipment is validated (and if your process is to make invoice on shipment and not on order), because this setup has changed.
* It was possible to use a variable $soc or $right inside a php code condition of some extrafields properties, this is no more true (this 2 variables are no more global variables).
* It was possible to use a variable $soc or $right inside a PHP code condition of some extrafields properties, this is no more true (this 2 variables are no more global variables).
* New hook files of modules actions_mymodule.class.php should now "extends CommonHookActions"
* Endpoint for API /partnershipapi and /recruitment has been renamed into /partnerships and /recruitments to follow name conventions.
***** ChangeLog for 18.0.3 compared to 18.0.2 *****
FIX: #25793 Cannot add time spent (#26405)
FIX: #26100 Ticket - On edit, list of closed project must be excluded (#26223)
FIX: #26170
FIX: #26195 Various payment - List of project excluded those assigned to third parties (#26222)
FIX: #26349 add_customer_ref_on_linked_shipment
FIX: avoid warning + CSRF
FIX: avoid warning if module not activated
FIX: Bad name for trigger in HRM module
FIX: check tva_tx before comparing price_min_ttc (#25220)
FIX: Compare the result of the send mail file function
FIX: dol_eval with function starting with !
FIX: Error handling for computed values on import (#24897)
FIX: Error not returned on sales with takepos and batch module enabled
FIX: error of webhook not returned
FIX: firstname and lastname were not saved in attendee subscription
FIX: HTML in ODT templates (#26181)
FIX: Link to list of movement from the inventory code
FIX: Mass import of stock from a file must accept empty source
FIX: Max version of PHP (#26327)
FIX: missing load group members for ldap synchro (#26167)
FIX: missing project entity filter (Issue #26243) (#26247)
FIX: modification of complementary attributes in invoices (#26180)
FIX: On object validation, ecm index are not updated for uploaded files
FIX: Propal's negative quantities
FIX: public subscription page should not display acceptation for public register when it is not enabled (#26354)
FIX: regression on rounding stocks fields on product list
FIX: removed a non expected hidden input field in stockatdate page
FIX: src_object_id and ttype not filed when uploading a file with API.
FIX: suggested end for membership can be before subscription start (#26351)
FIX: Supplier card - VAT Reserve Charge - Undefined function isInEEC() (#26379)
FIX: syntax error
FIX: template invoice list extrafield filters (backport v17) (#26227)
FIX: Tooltip for search syntax must not appear on date fields
FIX: upload of files src_object_type
FIX: use event.key instead event.wich to avoid keyboard difference
FIX: Use of line->insert instead of line->create
FIX: user creation when LDAP is configured (#26332)
FIX: Wrong backtopage given for the stocktransfer button from the stocktransfer list (#26271)
***** ChangeLog for 18.0.2 compared to 18.0.1 *****
FIX: 17.0 PHP8: supplier invoice class

View file

@ -9,7 +9,7 @@ Dolibarr ERP & CRM is a modern software package that helps manage your organizat
It's an Open Source Software suite (written in PHP with optional JavaScript enhancements) designed for small, medium or large companies, foundations and freelancers.
You can freely use, study, modify or distribute it according to its licence.
You can freely use, study, modify or distribute it according to its license.
You can use it as a standalone application or as a web application to access it from the Internet or a LAN.
@ -49,7 +49,7 @@ On GNU/Linux, first check if your distribution has already packaged Dolibarr.
- Uncompress the downloaded .zip archive to copy the "dolibarr/htdocs" directory and all its files inside your web server root or get the files directly from GitHub (recommended if you know git as it makes it easier if you want to upgrade later):
`git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is main version like 3.6, 9.0, ...)
`git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is the main version like 3.6, 9.0, ...)
- Set up your web server to use "*dolibarr/htdocs*" as root if your web server does not have an already defined directory to point to.
@ -57,7 +57,7 @@ On GNU/Linux, first check if your distribution has already packaged Dolibarr.
- From your browser, go to the dolibarr "install/" page
The URL will depends on how you web setup was setup to point to your dolibarr installation. It may looks like:
The URL will depends on how your web setup was set up to point to your dolibarr installation. It may look like:
`http://localhost/dolibarr/htdocs/install/`
@ -71,7 +71,7 @@ On GNU/Linux, first check if your distribution has already packaged Dolibarr.
- Follow the installer instructions
### Saas/Cloud setup
### SaaS/Cloud setup
If you don't have time to install it yourself, you can try some commercial 'ready to use' Cloud offers (See [https://saas.dolibarr.org](https://saas.dolibarr.org)). However, this third solution is not free.
@ -81,7 +81,7 @@ Dolibarr supports upgrading, usually without the need for any (commercial) suppo
- At first make a backup of your Dolibarr files & then [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr)
- Check that your installed PHP version is supported by the new version [see PHP support](https://wiki.dolibarr.org/index.php/Releases).
- Overwrite all old files from 'dolibarr' directory with files provided into the new version's package.
- Overwrite all old files from the 'dolibarr' directory with files provided into the new version's package.
- At first next access, Dolibarr will redirect you to the "install/" page to follow the upgrade process.
 If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file in the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*").
@ -141,7 +141,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
Collaboration
- Shared calendar/agenda (with ical and vcal import/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
@ -168,20 +168,20 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Payment platforms integration (PayPal, Stripe, Paybox...)
- Email-Collector
(around 100 modules available by default, 1000+ on the addon market place)
(around 100 modules available by default, 1000+ on the addon marketplace)
### Other general features
- Multi-Language Support (Localization in most major languages)
- Multi-Users and groups with finely grained rights
- 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
- Very user-friendly and easy to use
- 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)
- Support a lot of country specific features:
- Support a lot of country-specific features:
- Spanish Tax RE and ISPF
- French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM)
- Canadian double taxes (federal/province) and other countries using cumulative VAT
@ -189,7 +189,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- 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 data privacy rules (europe GDPR, ...)
- Compatible with data privacy rules (Europe GDPR, ...)
- ...
- Flexible PDF & ODT generation for invoices, proposals, orders...
- ...
@ -204,7 +204,7 @@ See exact requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequ
### Extending
Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com).
Dolibarr can be extended with a lot of other external applications or modules from third-party developers available at the [DoliStore](https://www.dolistore.com).
## WHAT DOLIBARR CAN'T DO YET
@ -212,19 +212,19 @@ These are features that Dolibarr does **not** yet fully support:
- Tasks dependencies in projects
- Payroll module
- No native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc.
- No native embedded Webmail, but you can send emails to contacts in Dolibarr with e.g. offers, invoices, etc.
- Dolibarr can't do coffee (yet)
## DOCUMENTATION
Administrator, user, developer and translator's documentations are available along with other community resources in the [Wiki](https://wiki.dolibarr.org).
Administrator, user, developer and translator's documentation are available along with other community resources in the [Wiki](https://wiki.dolibarr.org).
## CONTRIBUTING
This project exists thanks to all the people who contribute.
Please read the instructions how to contribute (report a bug/error, a feature request, send code ...) [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]
Please read the instructions on how to contribute (report a bug/error, a feature request, send code ...) [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]
A view on Contributors:
A View on Contributors:
[![Dolibarr](https://opencollective.com/dolibarr/contributors.svg?width=890&button=false)](https://github.com/Dolibarr/dolibarr/graphs/contributors)

View file

@ -18,7 +18,7 @@ With
CKEDITOR (4.6.2):
CKEDITOR (4.22.1):
-----------------
* In ckeditor/ckeditor/contents.css
Replace:
@ -26,7 +26,12 @@ Replace:
With
body { ... margin: 5px;
* In ckeditor/ckeditor/ckeditor.js
Replace:
d.items&&
With
d&&d.items&&
ESCPOS:
-------

View file

@ -171,6 +171,7 @@ fi
if [ -s "$mydir/initdemopostsql.sql" ]; then
echo A file initdemopostsql.sql was found, we execute it.
echo "mysql -P$port $base < \"$mydir/initdemopostsql.sql\""
mysql -P$port $base < "$mydir/initdemopostsql.sql"
else
echo No file initdemopostsql.sql found, so no extra sql action done.

View file

@ -3,16 +3,47 @@
# Count number of commits per user and per versions (using date for version detection)
#
Releases=("17.0" "18.0" "develop")
Dates=("2023-02-01" "2023-08-31" "2050-01-01")
let "counter = 1"
Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "develop")
let "counter = 0"
echo "Copy script into /tmp/github_commits_perversion.sh"
cp $0 /tmp/github_commits_perversion.sh
echo "Delete /tmp/git"
rm -fr /tmp/git
echo "Create and go into /tmp/git"
mkdir /tmp/git
cd /tmp/git
git clone https://github.com/Dolibarr/dolibarr.git
cd /tmp/git/dolibarr
firstline=1
for i in "${Releases[@]}"
do
echo "=== $counter git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]}"
git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]}
echo -n "Total $i: "
git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l
if [ $firstline -eq 1 ]; then
firstline=0
continue
fi
#echo "=== Version $i (counter $counter):"
echo "=== Version $i (counter $counter):"
echo "Get common commit ID between origin/${Releases[counter]} and origin/${Releases[counter+1]}"
echo "git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}"
commitidcommon=`git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}`
echo "Found commitid=$commitidcommon"
echo "Checkout into version $i"
git checkout $i
#git shortlog -s -n --after=YYYY-MM-DD --before=YYYY-MM-DD | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt
git shortlog -s -n $commitidcommon.. | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt
#cat /tmp/github_commits_perversion.txt
echo "Total for version $i:"
echo -n "- Nb of commits: "
git log $commitidcommon.. --pretty=oneline | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion2.txt
cat /tmp/github_commits_perversion2.txt | wc -l
echo -n "- Nb of different authors: "
awk ' { print $2 } ' < /tmp/github_commits_perversion.txt | sort -u | wc -l
echo "======================="
echo
let "counter +=1"

57
dev/tools/make_sprite.sh Normal file
View file

@ -0,0 +1,57 @@
#!/bin/bash
# Based of: https://gist.github.com/jaymzcd/342399 and https://github.com/buren/flag-sprite-maker
# uses imagemagick to stich together all images in a folder and
# then writes a css file with the correct offsets along with a
# test html page for verification that its all good
# Usage:
# $ ./make_sprite.sh path class_name image_extension
set -euo pipefail
IFS=$'\n\t'
name='output'; # output will be placed in a folder named this
path="${1:-}" # Path to flag images
classname=${2:-flag}"-sprite"
ext="."${3:-png}; # the extension to iterate over for input files
css="$name/$classname.css";
html="$name/test.html";
rm -fr $name;
mkdir $name;
touch $css $html;
echo "Generating sprite file...";
convert $path*$ext -append $name/$classname$ext;
echo "Sprite complete! - Creating css & test output...";
echo -e "<html>\n<head>\n\t<link rel=\"stylesheet\" href=\"`basename $css`\" />\n</head>\n<body>\n\t<h1>Sprite test page</h1>\n" >> $html
echo -e ".$classname {\n\tbackground:url('$classname$ext') no-repeat top left; display:inline-block;\n}" >> $css;
counter=0;
offset=0;
for file in $path*$ext
do
width=`identify -format "%[fx:w]" "$file"`;
height=`identify -format "%[fx:h]" "$file"`;
idname=`basename "$file" $ext`;
clean=${idname// /-}
echo -e ".$classname.$clean {" >> $css;
echo -e "\tbackground-position:0 -${offset}px;" >> $css;
echo -e "\twidth: ${width}px;" >> $css;
echo -e "\theight: ${height}px;\n}" >> $css;
echo -e "<div style=\"display:inline-block;width:100px;\"><div style=\"overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap;\">$clean</div> <a href=\"#\" class=\"$classname $clean\"></a></div>\n" >> $html;
let offset+=$height;
let counter+=1;
echo -e "\t#$counter done";
done
echo -e "<h2>Full sprite:</h2>\n<img src=\"$classname$ext\" />" >> $html;
echo -e "</body>\n</html>" >> $html;
echo -e "\nComplete! - $counter sprites created, css written & test page output.";

View file

@ -40,6 +40,7 @@ $rowid = GETPOST('rowid', 'int');
$massaction = GETPOST('massaction', 'aZ09');
$optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search
$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
$search_account = GETPOST('search_account', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
@ -90,7 +91,7 @@ $arrayfields = array(
'aa.pcg_type'=>array('label'=>"Pcgtype", 'checked'=>1, 'help'=>'PcgtypeDesc'),
'categories'=>array('label'=>"AccountingCategories", 'checked'=>-1, 'help'=>'AccountingCategoriesDesc'),
'aa.reconcilable'=>array('label'=>"Reconcilable", 'checked'=>1),
'aa.import_key'=>array('label'=>"ImportId", 'checked'=>-1),
'aa.import_key'=>array('label'=>"ImportId", 'checked'=>-1, 'help'=>''),
'aa.active'=>array('label'=>"Activated", 'checked'=>1)
);

View file

@ -57,8 +57,8 @@ $list = array(
);
$list_binding = array(
'ACCOUNTING_DATE_START_BINDING',
'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER',
'ACCOUNTING_DATE_START_BINDING',
);
$error = 0;

View file

@ -435,8 +435,8 @@ if ($action != 'export_csv') {
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) {
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
}
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("AccountingDebit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("AccountingCredit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
// Hook fields

View file

@ -2,7 +2,7 @@
/* 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-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -164,12 +164,13 @@ $arrayfields = array(
'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.lettering_code'=>array('label'=>$langs->trans("Lettering"), 'checked'=>1),
't.debit'=>array('label'=>$langs->trans("AccountingDebit"), 'checked'=>1),
't.credit'=>array('label'=>$langs->trans("AccountingCredit"), '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, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100),
't.balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1),
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>-1),
't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>-1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>-1, 'position'=>1100),
);
if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) {
@ -260,9 +261,9 @@ if (empty($reshook)) {
$search_date_validation_endyear = '';
$search_date_validation_endmonth = '';
$search_date_validation_endday = '';
$search_lettering_code = '';
$search_debit = '';
$search_credit = '';
$search_lettering_code = '';
$search_not_reconciled = '';
$search_import_key = '';
$toselect = array();
@ -339,6 +340,10 @@ if (empty($reshook)) {
$param .= '&search_ledger_code[]='.urlencode($code);
}
}
if (!empty($search_lettering_code)) {
$filter['t.lettering_code'] = $search_lettering_code;
$param .= '&search_lettering_code='.urlencode($search_lettering_code);
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit='.urlencode($search_debit);
@ -347,10 +352,6 @@ if (empty($reshook)) {
$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);
@ -679,7 +680,6 @@ if (empty($reshook)) {
$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 .= dolGetButtonTitleSeparator();
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
}
@ -844,6 +844,13 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) {
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>';
}
// 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>';
}
// 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>';
@ -852,12 +859,9 @@ if (!empty($arrayfields['t.debit']['checked'])) {
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>';
// Balance
if (!empty($arrayfields['t.balance']['checked'])) {
print '<td></td>';
}
// Date export
if (!empty($arrayfields['t.date_export']['checked'])) {
@ -920,14 +924,17 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) {
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.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.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.balance']['checked'])) {
print_liste_field_titre($arrayfields['t.balance']['label'], "", "", "", $param, '', $sortfield, $sortorder, 'right ');
}
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 ');
@ -977,18 +984,23 @@ while ($i < min($num, $limit)) {
//if (empty($accountg)) $accountg = '-';
$colspan = 0; // colspan before field 'label of operation'
$colspanend = 3; // colspan after debit/credit
$colspanend = 0; // colspan after debit/credit
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
$colspan++;
}
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.lettering_code']['checked'])) { $colspan++; }
if (!empty($arrayfields['t.balance']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
$colspan++;
$colspanend--;
if (!empty($arrayfields['t.import_key']['checked'])) { $colspanend++; }
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
$colspanend++;
}
// Is it a break ?
@ -1003,7 +1015,7 @@ while ($i < min($num, $limit)) {
}
print '<td class="nowrap right">'.price(price2num($sous_total_debit, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_credit, 'MT')).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
if ($colspanend > 0) print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
@ -1020,7 +1032,7 @@ while ($i < min($num, $limit)) {
print price(price2num($sous_total_credit - $sous_total_debit, 'MT'));
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
if ($colspanend > 0) print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
@ -1189,6 +1201,14 @@ while ($i < min($num, $limit)) {
}
}
// Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print '<td class="center">'.$line->lettering_code.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Amount debit
if (!empty($arrayfields['t.debit']['checked'])) {
print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
@ -1213,12 +1233,16 @@ while ($i < min($num, $limit)) {
$totalarray['val']['totalcredit'] += $line->credit;
}
// Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print '<td class="center">'.$line->lettering_code.'</td>';
// Amount balance
if (!empty($arrayfields['t.balance']['checked'])) {
print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit + $line->debit - $sous_total_credit - $line->credit, 'MT')).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalbalance';
};
$totalarray['val']['totalbalance'] += $line->debit - $line->credit;
}
// Exported operation date
@ -1279,7 +1303,7 @@ if ($num > 0 && $colspan > 0) {
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_debit, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_credit, 'MT')).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
if ($colspanend > 0) print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
@ -1296,7 +1320,7 @@ if ($num > 0 && $colspan > 0) {
print price(price2num($sous_total_credit - $sous_total_debit, 'MT'));
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
if ($colspanend > 0) print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
@ -1308,7 +1332,9 @@ if (!empty($totalarray['val']['totaldebit'])) {
if (!empty($totalarray['val']['totalcredit'])) {
$totalarray['val']['totalcredit'] = price2num($totalarray['val']['totalcredit'], 'MT');
}
if (!empty($totalarray['val']['totalbalance'])) {
$totalarray['val']['totalbalance'] = price2num($totalarray['val']['totaldebit'] - $totalarray['val']['totalcredit'], 'MT');
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';

View file

@ -401,6 +401,7 @@ class AccountingAccount extends CommonObject
{
global $langs;
// TODO Looks a stupid check
$sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet";
$sql .= " WHERE fk_code_ventilation=".((int) $this->id).")";
$sql .= "UNION";
@ -496,7 +497,7 @@ class AccountingAccount extends CommonObject
$url = '';
$labelurl = '';
if (empty($option) || $option == 'ledger') {
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode($this->account_number) . '&search_accountancy_code_end=' . urlencode($this->account_number);
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode((isset($this->account_number) ? $this->account_number : '')) . '&search_accountancy_code_end=' . urlencode((isset($this->account_number) ? $this->account_number : ''));
$labelurl = $langs->trans("ShowAccountingAccountInLedger");
} elseif ($option == 'journals') {
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . urlencode($this->account_number) . '&search_accountancy_code_end=' . urlencode($this->account_number);

View file

@ -228,7 +228,7 @@ class AccountingJournal extends CommonObject
}
/**
* Return clicable name (with picto eventually)
* Return clickable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $withlabel 0=No label, 1=Include label of journal, 2=Include nature of journal
@ -281,7 +281,7 @@ class AccountingJournal extends CommonObject
}
$label_link = $this->code;
if ($withlabel != 2 && !empty($this->label)) {
if ($withlabel == 1 && !empty($this->label)) {
$label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$langs->transnoentities($this->label).($nourl ? '</span>' : '');
}
if ($withlabel == 2 && !empty($this->nature)) {

View file

@ -1176,7 +1176,6 @@ class BookKeeping extends CommonObject
$sql = 'SELECT';
$sql .= " t.numero_compte,";
$sql .= " t.label_compte,";
if (!empty($option)) {
$sql .= " t.subledger_account,";
$sql .= " t.subledger_label,";
@ -1221,11 +1220,11 @@ class BookKeeping extends CommonObject
if (!empty($option)) {
$sql .= " AND t.subledger_account IS NOT NULL";
$sql .= " AND t.subledger_account <> ''";
$sql .= " GROUP BY t.numero_compte, t.label_compte, t.subledger_account, t.subledger_label";
$sql .= " GROUP BY t.numero_compte, t.subledger_account, t.subledger_label";
$sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortfield ? ','.$sortfield : '');
} else {
$sql .= ' GROUP BY t.numero_compte, t.label_compte';
$sql .= ' GROUP BY t.numero_compte';
$sortfield = 't.numero_compte'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortorder ? ','.$sortorder : '');
}
@ -1246,7 +1245,7 @@ class BookKeeping extends CommonObject
$line = new BookKeepingLine();
$line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte;
//$line->label_compte = $obj->label_compte;
if (!empty($option)) {
$line->subledger_account = $obj->subledger_account;
$line->subledger_label = $obj->subledger_label;

View file

@ -319,9 +319,9 @@ if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
$y = $year_current;
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'">'.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").'</a>';
$buttonbind = '<a class="button small" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'">'.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").'</a>';
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind);
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">';

View file

@ -74,6 +74,11 @@ $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_en
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Define begin binding date
if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
$search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING);
}
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'aZ09comma');
@ -281,10 +286,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_so
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
// Define begin binding date
if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Add search filter like
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);

View file

@ -193,10 +193,10 @@ print '</span><br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'&year='.$year_current.'">'.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").'</a>';
$buttonbind = '<a class="button small" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'&year='.$year_current.'">'.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").'</a>';
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind);
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">';

View file

@ -67,6 +67,11 @@ $search_date_endyear = GETPOST('search_date_endyear', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
// Define begin binding date
if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
$search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING);
}
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'aZ09comma');
@ -240,10 +245,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_f
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
// Define begin binding date
if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Add search filter like
if (strlen(trim($search_login))) {
$sql .= natural_search("u.login", $search_login);
@ -291,6 +292,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
$offset = 0;
}
}
//print $sql;
$sql .= $db->plimit($limit + 1, $offset);

View file

@ -3,11 +3,11 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.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
@ -71,6 +71,9 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
$error = 0;
$errorforinvoice = array();
/*
* Actions
@ -213,8 +216,27 @@ if ($result) {
dol_print_error($db);
}
// Load all unbound lines
$sql = "SELECT fk_expensereport, COUNT(erd.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " WHERE erd.fk_code_ventilation <= 0";
$sql .= " AND erd.total_ttc <> 0";
$sql .= " AND fk_expensereport IN (".$db->sanitize(join(",", array_keys($taber))).")";
$sql .= " GROUP BY fk_expensereport";
$resql = $db->query($sql);
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj->nb > 0) {
$errorforinvoice[$obj->fk_expensereport] = 'somelinesarenotbound';
}
$i++;
}
// Bookkeeping Write
if ($action == 'writebookkeeping') {
if ($action == 'writebookkeeping' && !$error) {
$now = dol_now();
$error = 0;
@ -229,6 +251,13 @@ if ($action == 'writebookkeeping') {
$db->begin();
// Error if some lines are not binded/ready to be journalized
if (!empty($errorforinvoice[$key]) && $errorforinvoice[$key] == 'somelinesarenotbound') {
$error++;
$errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
}
// Thirdparty
if (!$errorforline) {
foreach ($tabttc[$key] as $k => $mt) {
@ -265,10 +294,12 @@ if ($action == 'writebookkeeping') {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
$error++;
$errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} else {
$error++;
$errorforline++;
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
@ -314,10 +345,12 @@ if ($action == 'writebookkeeping') {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
$error++;
$errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} else {
$error++;
$errorforline++;
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
@ -376,10 +409,12 @@ if ($action == 'writebookkeeping') {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
$error++;
$errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} else {
$error++;
$errorforline++;
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
@ -388,10 +423,11 @@ if ($action == 'writebookkeeping') {
}
}
// Protection against a bug on line before
if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) {
// Protection against a bug on lines before
if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) {
$error++;
$errorforline++;
$errorforinvoice[$key] = 'amountsnotbalanced';
setEventMessages('We tried to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors');
}
@ -445,7 +481,7 @@ $form = new Form($db);
$userstatic = new User($db);
// Export
if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$filename = 'journal';
@ -586,7 +622,7 @@ if (empty($action) || $action == 'view') {
print '<td class="right">'.$langs->trans("AccountingCredit")."</td>";
print "</tr>\n";
$r = '';
$i = 0;
$expensereportstatic = new ExpenseReport($db);
$expensereportlinestatic = new ExpenseReportLine($db);
@ -598,6 +634,27 @@ if (empty($action) || $action == 'view') {
$date = dol_print_date($val["date"], 'day');
if ($errorforinvoice[$key] == 'somelinesarenotbound') {
print '<tr class="oddeven">';
print "<!-- Some lines are not bound -->";
print "<td>".$date."</td>";
print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
// Account
print "<td>";
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
print '</td>';
// Subledger account
print "<td>";
print '</td>';
print "<td>";
print "</td>";
print '<td class="right"></td>';
print '<td class="right"></td>';
print "</tr>";
$i++;
}
// Fees
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);

View file

@ -311,10 +311,10 @@ print '</span><br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'">'.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").'</a>';
$buttonbind = '<a class="button small" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'">'.img_picto('', 'link', 'class="paddingright fa-color-unset smallpaddingimp"').$langs->trans("ValidateHistory").'</a>';
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind);
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">';

View file

@ -117,6 +117,11 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
// Define begin binding date
if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
$search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING);
}
/*
* Actions
@ -282,10 +287,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_pr
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
// Define begin binding date
if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Add search filter like
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);

View file

@ -9,6 +9,7 @@
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2020-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2023 Waël Almoman <info@almoman.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -103,13 +104,15 @@ if ($action == 'set_default') {
}
} elseif ($action == 'updatemainoptions') {
$db->begin();
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = $res7 = 0;
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = $res7 = $res8 = $res9 = 0;
$res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
$res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
$res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity);
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
$res7 = dolibarr_set_const($db, 'MEMBER_PUBLIC_ENABLED', GETPOST('MEMBER_PUBLIC_ENABLED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res8 = dolibarr_set_const($db, 'MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF', GETPOST('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF', 'alpha'), 'chaine', 0, '', $conf->entity);
$res9 = dolibarr_set_const($db, 'MEMBER_SUBSCRIPTION_START_AFTER', GETPOST('MEMBER_SUBSCRIPTION_START_AFTER', 'alpha'), 'chaine', 0, '', $conf->entity);
// Use vat for invoice creation
if (isModEnabled('facture')) {
$res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -335,6 +338,24 @@ print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
// Start date of new membership
$startpoint[0] = $langs->trans("SubscriptionPayment");
$startpoint["m"] = $langs->trans("Month");
$startpoint["Y"] = $langs->trans("Year");
print '<tr class="oddeven drag" id="startfirstdayof"><td>';
print $langs->trans("MemberSubscriptionStartFirstDayOf");
print '</td><td>';
$startfirstdayof = !getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') ? 0 : getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF');
print $form->selectarray("MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF", $startpoint, $startfirstdayof, 0);
print "</td></tr>\n";
// Delay to start the new membership ([+/-][0-99][Y/m/d], for instance, with "+4m", the subscription will start in 4 month.)
print '<tr class="oddeven drag" id="startfirstdayof"><td>';
print $langs->trans("MemberSubscriptionStartAfter");
print '</td><td>';
print '<input type="text" class="right width50" id="MEMBER_SUBSCRIPTION_START_AFTER" name="MEMBER_SUBSCRIPTION_START_AFTER" value="'.(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER') ? getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER') : '').'">';
print "</td></tr>\n";
// Mail required for members
print '<tr class="oddeven"><td>'.$langs->trans("AdherentMailRequired").'</td><td>';
print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1);

View file

@ -282,7 +282,7 @@ class AdherentStats extends Stats
$sql .= " GROUP BY c.rowid, c.label";
$sql .= " ORDER BY label ASC";
dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG);
dol_syslog("box_members_by_tag::select nb of members per tag", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {

View file

@ -48,8 +48,11 @@ if ($user->socid > 0) {
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$startyear = $year - (!getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) {
$endyear = dol_print_date(dol_time_plus_duree(dol_now('gmt'), (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1)), "%Y", 'gmt');
}
// Load translation files required by the page
$langs->loadLangs(array("companies", "members"));

View file

@ -6,6 +6,7 @@
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2023 Waël Almoman <info@almoman.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -53,7 +54,7 @@ $typeid = GETPOST('typeid', 'int');
$cancel = GETPOST('cancel');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@ -81,9 +82,6 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$errmsg = '';
$defaultdelay = 1;
$defaultdelayunit = 'y';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('subscription'));
@ -213,6 +211,8 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscripti
// Subscription informations
$datesubscription = 0;
$datesubend = 0;
$defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
$defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y';
$paymentdate = ''; // Do not use 0 here, default value is '' that means not filled where 0 means 1970-01-01
if (GETPOST("reyear", "int") && GETPOST("remonth", "int") && GETPOST("reday", "int")) {
$datesubscription = dol_mktime(0, 0, 0, GETPOST("remonth", "int"), GETPOST("reday", "int"), GETPOST("reyear", "int"));
@ -476,6 +476,9 @@ if (! ($object->id > 0)) {
$adht->fetch($object->typeid);
$defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
$defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y';
$head = member_prepare_head($object);
$rowspan = 10;
@ -958,8 +961,6 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
print '<table class="border centpercent">'."\n";
print '<tbody>';
$now = dol_now();
// Date payment
if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) {
$paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
@ -975,10 +976,16 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
}
if (!$datefrom) {
$datefrom = $object->datevalid;
if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > dol_now()) {
if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) {
$datefrom = dol_time_plus_duree($now, (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1));
} elseif ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > $now) {
$datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
} else {
$datefrom = dol_get_first_day($currentyear);
}
if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "m") {
$datefrom = dol_get_first_day(dol_print_date($datefrom, "%Y"), dol_print_date($datefrom, "%m"));
} elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "Y") {
$datefrom = dol_get_first_day(dol_print_date($datefrom, "%Y"));
}
}
print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1);
@ -990,9 +997,9 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
}
if (!$dateto) {
if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) {
$dateto = dol_get_last_day($currentyear, $currentmonth);
$dateto = dol_get_last_day(dol_print_date($datefrom, "%Y"), dol_print_date($datefrom, "%m"));
} elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) {
$dateto = dol_get_last_day($currentyear);
$dateto = dol_get_last_day(dol_print_date($datefrom, "%Y"));
} else {
$dateto = -1; // By default, no date is suggested
}

View file

@ -57,7 +57,7 @@ $modules = array(
'MAILING' => 'FCKeditorForMailing',
'MAIL' => 'FCKeditorForMail',
'TICKET' => 'FCKeditorForTicket',
'SPECIALCHAR' => 'SpecialChar activation',
'SPECIALCHAR' => 'SpecialCharActivation',
);
// Conditions for the option to be offered
$conditions = array(
@ -100,13 +100,9 @@ foreach ($modules as $const => $desc) {
if ($const == 'PRODUCTDESC' && getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity);
}
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
if ($action == 'disable_'.strtolower($const)) {
dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "0", 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
}
@ -179,9 +175,9 @@ if (empty($conf->use_javascript_ajax)) {
print '<td class="center centpercent width100">';
$value = (isset($conf->global->$constante) ? $conf->global->$constante : 0);
if ($value == 0) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=enable_'.strtolower($const).'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=enable_'.strtolower($const).'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} elseif ($value == 1) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=disable_'.strtolower($const).'&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=disable_'.strtolower($const).'&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
}
print "</td>";

View file

@ -934,7 +934,7 @@ foreach ($fieldlist as $field => $value) {
if ($value == 'module') {
print '<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).'"></td>';
} elseif ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" 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, 'maxwidth100');
@ -1227,7 +1227,7 @@ if ($num) {
$valuetoshow = dol_escape_htmltag($valuetoshow);
}
if ($value == 'label') {
$class .= ' tdoverflowmax100';
$class .= ' tdoverflowmax200';
}
if ($value == 'topic') {
$class .= ' tdoverflowmax200 small';

View file

@ -215,7 +215,7 @@ if ($conf->use_javascript_ajax) {
print '</td></tr>';
// Online payment with currency on document. This option should be on by default.
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").'</td>';
print '<td class="center">';
@ -260,51 +260,6 @@ print '</td></tr>';
print '</table>';
print '</div>';
print '<br>';
if (getDolGlobalString('MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION')) {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" id="form_sync">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setapilayer">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$urlforapilayer = 'https://currencylayer.com'; //https://apilayer.net
print '<tr class="liste_titre">';
print '<td>'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'</td>'."\n";
print '<td class="right">';
print '<textarea id="response" class="hideobject" name="response"></textarea>';
print '<input type="submit" name="modify_apilayer" class="button buttongen" value="'.$langs->trans("Modify").'">';
print '<input type="submit" id="bt_sync" name="bt_sync_apilayer" class="button buttongen" value="'.$langs->trans('Synchronize').'" />';
print '</td></tr>';
print '<tr class="oddeven">';
print '<td class="fieldrequired"><a target="_blank" rel="noopener noreferrer external" href="'.$urlforapilayer.'">'.$langs->transnoentitiesnoconv("multicurrency_appId").'</a></td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_APP_ID" value="' . getDolGlobalString('MULTICURRENCY_APP_ID').'" size="28" />&nbsp;';
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").'</td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_APP_SOURCE" value="' . getDolGlobalString('MULTICURRENCY_APP_SOURCE').'" size="10" placeholder="USD" />&nbsp;'; // Default: USD
print '</form>';
print '</td></tr>';
/*print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE.'" size="10" placeholder="EUR" />&nbsp;'; // Example: EUR
print '</td></tr>';*/
print '</table>';
print '</div>';
print '<br>';
print '</form>';
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent nomarginbottom">';
@ -377,6 +332,53 @@ print '
</script>
';
print '<br>';
if (!getDolGlobalString('MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER')) {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" id="form_sync">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setapilayer">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$urlforapilayer = 'https://currencylayer.com'; //https://apilayer.net
print '<tr class="liste_titre">';
print '<td>'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'</td>'."\n";
print '<td class="right">';
print '<textarea id="response" class="hideobject" name="response"></textarea>';
print '<input type="submit" name="modify_apilayer" class="button buttongen" value="'.$langs->trans("Modify").'">';
print '<input type="submit" id="bt_sync" name="bt_sync_apilayer" class="button buttongen" value="'.$langs->trans('Synchronize').'" />';
print '</td></tr>';
print '<tr class="oddeven">';
print '<td class="fieldrequired"><a target="_blank" rel="noopener noreferrer external" href="'.$urlforapilayer.'">'.$langs->transnoentitiesnoconv("multicurrency_appId").'</a></td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_APP_ID" value="' . getDolGlobalString('MULTICURRENCY_APP_ID').'" size="28" />&nbsp;';
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").'</td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_APP_SOURCE" value="' . getDolGlobalString('MULTICURRENCY_APP_SOURCE').'" size="10" placeholder="USD" />&nbsp;'; // Default: USD
print '</td></tr>';
/*print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td class="right">';
print '<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE.'" size="10" placeholder="EUR" />&nbsp;'; // Example: EUR
print '</td></tr>';*/
print '</table>';
print '</div>';
print '<br>';
print '</form>';
}
// End of page
llxFooter();
$db->close();

View file

@ -132,6 +132,10 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE')) {
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE"), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET('MAIN_DOCUMENTS_LOGO_HEIGHT')) {
dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity);
}
@ -532,6 +536,18 @@ if ($conf->use_javascript_ajax) {
}
print '</td></tr>';
// Barcode
if (isModEnabled('barcode')) {
print '<tr class="oddeven"><td>'.$langs->trans("ShowProductBarcodeOnPDF").'</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE');
} else {
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE : 0, 1);
}
print '</td></tr>';
}
// Desc
print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>';

View file

@ -638,7 +638,7 @@ print '<br>';
print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1)</span>')."<br>";
print '<br>';
print '<strong>MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS</strong> = '.getDolGlobalString('MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
print '<strong>MAIN_DISALLOW_URL_INTO_DESCRIPTIONS</strong> = '.getDolGlobalString('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1)</span>')."<br>";
print '<br>';
print '<strong>MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS</strong> = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";

View file

@ -28,6 +28,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/triggers/interface_20_all_Logevents.class.php';
if (!$user->admin) {
accessforbidden();
@ -477,6 +478,10 @@ if ($result) {
// Description
$text = $langs->trans($obj->description);
$reg = array();
if (InterfaceLogevents::isEventActionTextKey($obj->description)) {
$val = explode(' : ', $obj->description);
$text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : '');
}
if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg)) {
$val = explode(',', $reg[1]);
$text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : '');

View file

@ -55,12 +55,7 @@ $setupnotempty = 0;
$useFormSetup = 1;
if (!class_exists('FormSetup')) {
// For retrocompatibility Dolibarr < 16.0
if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) {
require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php';
} else {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
$formSetup = new FormSetup($db);

View file

@ -68,12 +68,7 @@ if (!$user->admin || !isModEnabled('website')) {
$useFormSetup = 1;
if (!class_exists('FormSetup')) {
// For retrocompatibility Dolibarr < 16.0
if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) {
require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php';
} else {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
$formSetup = new FormSetup($db);

View file

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/iUs
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/Resources.php';
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/Defaults.php';
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/RestException.php';
use Luracast\Restler\iAuthenticate;
use Luracast\Restler\iUseAuthentication;
use Luracast\Restler\Resources;

View file

@ -22,7 +22,7 @@ use Luracast\Restler\RestException;
use Luracast\Restler\Format\UploadFormat;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
/**
@ -596,7 +596,9 @@ class Documents extends DolibarrApi
} elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) {
$count = count($filearray);
for ($i = 0 ; $i < $count ; $i++) {
if ($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]);
if ($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) {
$filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]);
}
}
}
}
@ -621,7 +623,7 @@ class Documents extends DolibarrApi
/**
* Upload a file.
* Upload a document.
*
* Test sample for invoice: { "filename": "mynewfile.txt", "modulepart": "invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
@ -654,14 +656,12 @@ class Documents extends DolibarrApi
//var_dump($filename);
//var_dump($filecontent);exit;
$modulepartorig = $modulepart;
if (empty($modulepart)) {
throw new RestException(400, 'Modulepart not provided.');
}
if (!DolibarrApiAccess::$user->rights->ecm->upload) {
throw new RestException(401);
}
$newfilecontent = '';
if (empty($fileencoding)) {
$newfilecontent = $filecontent;
@ -783,10 +783,17 @@ class Documents extends DolibarrApi
$tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier');
}
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref);
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
// Test on permissions
if ($modulepart != 'ecm') {
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref);
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
} else {
if (!DolibarrApiAccess::$user->hasRight('ecm', 'upload')) {
throw new RestException(401, 'Missing permission to upload files in ECM module');
}
$upload_dir = $conf->medias->multidir_output[$conf->entity];
}
if (empty($upload_dir) || $upload_dir == '/') {
throw new RestException(500, 'This value of modulepart ('.$modulepart.') does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
@ -799,9 +806,17 @@ class Documents extends DolibarrApi
$modulepart = 'adherent';
}
$relativefile = $subdir;
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
// Test on permissions
if ($modulepart != 'ecm') {
$relativefile = $subdir;
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
} else {
if (!DolibarrApiAccess::$user->hasRight('ecm', 'upload')) {
throw new RestException(401, 'Missing permission to upload files in ECM module');
}
$upload_dir = $conf->medias->multidir_output[$conf->entity];
}
if (empty($upload_dir) || $upload_dir == '/') {
if (!empty($tmp['error'])) {
@ -891,7 +906,14 @@ class Documents extends DolibarrApi
throw new RestException(500, "Refused to deliver file ".$dest_file);
}
$result = dol_move($destfiletmp, $dest_file, 0, $overwriteifexists, 1, 1);
$moreinfo = array('note_private' => 'File uploaded using API /documents from IP '.getUserRemoteIP());
if (!empty($object) && is_object($object) && $object->id > 0) {
$moreinfo['src_object_type'] = $object->table_element;
$moreinfo['src_object_id'] = $object->id;
}
// Move the temporary file at its final emplacement
$result = dol_move($destfiletmp, $dest_file, 0, $overwriteifexists, 1, 1, $moreinfo);
if (!$result) {
throw new RestException(500, "Failed to move file into '".$destfile."'");
}

View file

@ -24,7 +24,7 @@
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/cstate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/cregion.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';

View file

@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
require_once DOL_DOCUMENT_ROOT.'/api/class/api.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';

View file

@ -363,7 +363,7 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
}
}
dol_syslog('Search api file /'.$moduledirforclass.'/class/api_'.$classfile.'.class.php => dir_part_file='.$dir_part_file.' classname='.$classname);
dol_syslog('Search api file /'.$moduledirforclass.'/class/api_'.$classfile.'.class.php => dir_part_file='.$dir_part_file.', classname='.$classname);
$res = false;
if ($dir_part_file) {

View file

@ -1466,12 +1466,10 @@ class Asset extends CommonObject
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->user_creation_id = $obj->fk_user_author;
$this->user_validation_id = $obj->fk_user_valid;
$this->user_closing_id = $obj->fk_user_cloture;
$this->user_creation_id = $obj->fk_user_creat;
$this->user_modification_id = $obj->fk_user_modif;
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datem);
$this->date_validation = $this->db->jdate($obj->datev);
}
$this->db->free($result);

View file

@ -73,7 +73,7 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->asset->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object);
}
$permissiontoadd = $user->rights->asset->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
// Security check (enable the most restrictive one)
if ($user->socid > 0) accessforbidden();

View file

@ -540,6 +540,7 @@ if (is_array($blocks)) {
$nbshown = 0;
$MAXFORSHOWLINK = 100;
$object_link = '';
$object_link_title = '';
foreach ($blocks as &$block) {
//if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
@ -548,8 +549,10 @@ if (is_array($blocks)) {
if ($nbshown < $MAXFORSHOWLINK) { // For performance and memory purpose, we get/show the link of objects only for the 100 first output
$object_link = $block->getObjectLink();
$object_link_title = '';
} else {
$object_link = $block->element.'/'.$block->fk_object;
$object_link_title = $langs->trans('LinkHasBeenDisabledForPerformancePurpose');
}
print '<tr class="oddeven">';
@ -581,7 +584,7 @@ if (is_array($blocks)) {
print '</td>';
// Link to source object
print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link)).'"').'>';
print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.' - '.$object_link_title)).'"').'>';
print '<!-- object_link -->'; // $object_link can be a '<a href' link or a text
print $object_link;
print '</td>';

View file

@ -177,6 +177,7 @@ if (empty($reshook)) {
$product = new Product($db);
$res = $product->fetch($idprod);
if ($res > 0 && $product->type == Product::TYPE_SERVICE) $fk_default_workstation = $product->fk_default_workstation;
if (empty($fk_unit)) $fk_unit = $product->fk_unit;
}
if ($qty == '') {

View file

@ -780,9 +780,9 @@ class BOM extends CommonObject
$line->efficiency = $efficiency;
$line->import_key = $import_key;
$line->position = $rankToUse;
if (!empty($fk_unit)) {
$line->fk_unit = $fk_unit;
}
if (!empty($fk_unit)) $line->fk_unit = $fk_unit;
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
@ -987,6 +987,12 @@ class BOM extends CommonObject
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'bom/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);

View file

@ -128,7 +128,8 @@ print '</td>';
if ($filtertype != 1) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';
print '<td class="nobottom nowrap linecolunit right">';
print $formproduct->selectMeasuringUnits("fk_unit", '', (($line->fk_unit) ? $line->fk_unit : ''), 0, 0);
print '</td>';
}

View file

@ -128,7 +128,7 @@ print '</td>';
if ($filtertype != 1) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit nowrap left">';
$label = $tmpproduct->getLabelOfUnit('long');
$label = measuringUnitString($line->fk_unit, '', '', 1);
if ($label !== '') {
print $langs->trans($label);
}

View file

@ -1,8 +1,8 @@
# BOOKCAL FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
# ONLINE APPOINTMENT FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
## Features
Provide features to be able to record online booking.
Provides an online appointment booking system. This allow anyone to book rendez-vous, according to predefined ranges or availabilities.
<!--
![Screenshot bookcal](img/screenshot_bookcal.png?raw=true "BookCal"){imgmd}

View file

@ -61,12 +61,7 @@ $setupnotempty = 0;
$useFormSetup = 1;
if (!class_exists('FormSetup')) {
// For retrocompatibility Dolibarr < 16.0
if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) {
require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php';
} else {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
$formSetup = new FormSetup($db);

View file

@ -242,6 +242,7 @@ if ($object->id > 0) {
print '</div>';
/*
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
$param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : '');
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
@ -253,14 +254,12 @@ if ($object->id > 0) {
// Try to know count of actioncomm from cache
$nbEvent = 0;
/*require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_myobject_'.$object->id;
$nbEvent = dol_getcache($cachekey);
print_barre_liste($langs->trans("ActionsOnMyObject").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
*/
//require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
//$cachekey = 'count_events_myobject_'.$object->id;
//$nbEvent = dol_getcache($cachekey);
$titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': '');
print load_fiche_titre($titlelist, '', '');
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
// List of all actions
$filters = array();
@ -270,6 +269,7 @@ if ($object->id > 0) {
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}
*/
}
// End of page

View file

@ -291,7 +291,7 @@ if ($object->id > 0) {
}
}
/*
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
print '<br>';
@ -305,12 +305,9 @@ if ($object->id > 0) {
// Try to know count of actioncomm from cache
$nbEvent = 0;
/*require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_myobject_'.$object->id;
$nbEvent = dol_getcache($cachekey);
print_barre_liste($langs->trans("ActionsOnMyObject").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
*/
//require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
//$cachekey = 'count_events_myobject_'.$object->id;
//$nbEvent = dol_getcache($cachekey);
$titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': '');
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
@ -322,6 +319,7 @@ if ($object->id > 0) {
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, property_exists($object, 'module') ? $object->module : '');
}
*/
}
// End of page

View file

@ -353,36 +353,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
if ($action == 'generate') {
print '<i> Link : </i> <strong> <a href="'. DOL_URL_ROOT.'/public/bookcal/index.php?id='.$object->id . '">Public page</a></strong>' ;
}
// Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
if ($action == 'xxx') {
$text = $langs->trans('ConfirmActionCalendar', $object->ref);
/*if (isModEnabled('notification'))
{
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
$notify = new Notify($db);
$text .= '<br>';
$text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
}*/
$formquestion = array();
/*
$forcecombo=0;
if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
);
*/
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
}
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@ -452,6 +422,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Link to public page
print '<tr><td>Link</td>';
print '<td><a href="'. DOL_URL_ROOT.'/public/bookcal/index.php?id='.$object->id.'" target="_blank">Public page</a>';
print '</td></tr>';
print '</table>';
print '</div>';
print '</div>';
@ -524,9 +499,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (empty($reshook)) {
// Send
if (empty($user->socid)) {
/*if (empty($user->socid)) {
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
}
}*/
// Back to draft
if ($object->status == $object::STATUS_VALIDATED) {
@ -550,10 +525,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
}
// Generate link
if ($object->status == Calendar::STATUS_VALIDATED) {
print dolGetButtonAction($langs->trans('generateLink'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=generate', '', $permissiontoadd);
}
/*
if ($permissiontoadd) {
if ($object->status == $object::STATUS_ENABLED) {
@ -584,6 +555,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$action = 'presend';
}
/*
if ($action != 'presend') {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
@ -632,6 +604,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$trackid = 'calendar'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
*/
}
// End of page

View file

@ -114,8 +114,8 @@ class Availabilities extends CommonObject
*/
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"BookcalLabelAvailabilityHelp", 'showoncombobox'=>'2', 'validate'=>'1',),
'fk_bookcal_calendar' => array('type'=>'integer:Calendar:bookcal/class/calendar.class.php:1', 'label'=>'Calendar', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax150', 'cssview'=>'wordbreak', 'help'=>"BookcalLabelAvailabilityHelp", 'showoncombobox'=>'2', 'validate'=>'1',),
'fk_bookcal_calendar' => array('type'=>'integer:Calendar:bookcal/class/calendar.class.php:1', 'label'=>'Calendar', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax100'),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
@ -129,9 +129,9 @@ class Availabilities extends CommonObject
'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,),
'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,),
'duration' => array('type'=>'integer', 'label'=>'DurationOfRange', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30', 'css'=>'width50 right'),
'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>-1,),
'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Closed'), 'validate'=>'1'),
'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>1,),
'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Closed'), 'default'=>1, 'validate'=>'1'),
);
public $rowid;
public $label;
@ -588,6 +588,12 @@ class Availabilities extends CommonObject
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'availabilities/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'availabilities/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@ -893,15 +899,17 @@ class Availabilities extends CommonObject
global $langs;
//$langs->load("agenda");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Closed');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Closed');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
}
$statusType = 'status'.$status;
//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
if ($status == self::STATUS_VALIDATED) {
$statusType = 'status4';
}
if ($status == self::STATUS_CANCELED) {
$statusType = 'status6';
}

View file

@ -117,6 +117,8 @@ class Calendar extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'right', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object", 'css'=>'width100'),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'alwayseditable'=>'1', 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',),
'visibility' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Owner', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'picto'=>'user', 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>42, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '3'=>'Other'),),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150', 'help'=>"ThirdPartyBookCalHelp", 'validate'=>'1',),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'isModEnabled("project")', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150', 'validate'=>'1',),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
@ -127,13 +129,13 @@ class Calendar extends CommonObject
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax150',),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax150',),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '3'=>'Other'),),
'visibility' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Owner', 'enabled'=>'1', 'position'=>41, 'notnull'=>1, 'visible'=>1, 'picto'=>'user', 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'default'=>0, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Closed'), 'validate'=>'1',),
);
public $rowid;
public $ref;
public $label;
public $type;
public $visibility;
public $fk_soc;
public $fk_project;
public $description;
@ -145,47 +147,9 @@ class Calendar extends CommonObject
public $fk_user_modif;
public $import_key;
public $status;
public $type;
public $visibility;
// END MODULEBUILDER PROPERTIES
// If this object has a subtable with lines
// /**
// * @var string Name of subtable line
// */
// public $table_element_line = 'bookcal_calendarline';
// /**
// * @var string Field with ID of parent key if this object has a parent
// */
// public $fk_element = 'fk_calendar';
// /**
// * @var string Name of subtable class that manage subtable lines
// */
// public $class_element_line = 'Calendarline';
// /**
// * @var array List of child tables. To test if we can delete object.
// */
// protected $childtables = array('mychildtable' => array('name'=>'Calendar', 'fk_element'=>'fk_calendar'));
// /**
// * @var array List of child tables. To know object to delete on cascade.
// * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
// * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
// */
// protected $childtablesoncascade = array('bookcal_calendardet');
// /**
// * @var CalendarLine[] Array of subtable lines
// */
// public $lines = array();
/**
* Constructor
*
@ -193,7 +157,7 @@ class Calendar extends CommonObject
*/
public function __construct(DoliDB $db)
{
global $conf, $langs;
global $langs, $user;
$this->db = $db;
@ -209,6 +173,7 @@ class Calendar extends CommonObject
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
$this->fields['visibility']['default'] = $user->id;
// Unset fields that are disabled
foreach ($this->fields as $key => $val) {
@ -387,8 +352,6 @@ class Calendar extends CommonObject
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$records = array();
@ -507,7 +470,7 @@ class Calendar extends CommonObject
*/
public function validate($user, $notrigger = 0)
{
global $conf, $langs;
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -582,6 +545,12 @@ class Calendar extends CommonObject
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'calendar/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'calendar/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@ -704,7 +673,7 @@ class Calendar extends CommonObject
*/
public function getTooltipContentArray($params)
{
global $conf, $langs;
global $langs;
$datas = [];
@ -917,7 +886,7 @@ class Calendar extends CommonObject
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("bookcal@bookcal");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
@ -927,7 +896,9 @@ class Calendar extends CommonObject
}
$statusType = 'status'.$status;
//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
if ($status == self::STATUS_VALIDATED) {
$statusType = 'status4';
}
if ($status == self::STATUS_CANCELED) {
$statusType = 'status6';
}
@ -1012,7 +983,7 @@ class Calendar extends CommonObject
public function getNextNumRef()
{
global $langs, $conf;
$langs->load("bookcal@bookcal");
$langs->load("agenda");
if (getDolGlobalString('BOOKCAL_MYOBJECT_ADDON')) {
$conf->global->BOOKCAL_MYOBJECT_ADDON = 'mod_calendar_standard';
@ -1077,7 +1048,7 @@ class Calendar extends CommonObject
$result = 0;
$includedocgeneration = 0;
$langs->load("bookcal@bookcal");
$langs->load("agenda");
if (!dol_strlen($modele)) {
$modele = 'standard_calendar';

View file

@ -31,18 +31,18 @@ function calendarPrepareHead($object)
{
global $db, $langs, $conf;
$langs->load("bookcal@bookcal");
$langs->load("agenda");
$showtabofpagecontact = 0;
$showtabofpagenote = 1;
$showtabofpagedocument = 1;
$showtabofpagedocument = 0;
$showtabofpageagenda = 1;
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/bookcal/calendar_card.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][1] = $langs->trans("Calendar");
$head[$h][2] = 'card';
$h++;

View file

@ -1594,6 +1594,7 @@ class ActionComm extends CommonObject
// Set label of type
$labeltype = '';
if ($this->type_code) {
$langs->load("commercial");
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label;
}
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
@ -1697,6 +1698,7 @@ class ActionComm extends CommonObject
// Set label of type
$labeltype = '';
if ($this->type_code) {
$langs->load("commercial");
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label;
}
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {

View file

@ -711,7 +711,7 @@ $newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-c
$param .= '&mode='.$mode;
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, is_numeric($nbtotalofrecords) ? -1 * $nbtotalofrecords: $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
print $s;

View file

@ -0,0 +1,159 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
*
* 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/comm/mailing/note.php
* \ingroup mailing
* \brief Tab for notes on Mailings
*/
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("mailing", "companies"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
// Initialize technical objects
$object = new Mailing($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->mailing->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('mailingnote', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->mailing->multidir_output[$object->entity]."/".$object->id;
}
$permissionnote = $user->hasRight('mailing', 'write'); // Used by the include of actions_setnotes.inc.php
$permissiontoadd = $user->hasRight('mailing', 'write'); // Used by the include of actions_addupdatedelete.inc.php
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, '', '', 'rowid', $isdraft);
/*
* Actions
*/
$reshook = $hookmanager->executeHooks('doActions', array(), $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_setnotes.inc.php'; // Must be include, not include_once
}
/*
* View
*/
$form = new Form($db);
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
$help_url = '';
llxHeader('', $langs->trans('Mailing'), $help_url);
if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = emailing_prepare_head($object);
print dol_get_fiche_head($head, 'note', $langs->trans("Mailing"), -1, $object->picto);
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.dol_buildpath('/knowledgemanagement/knowledgerecord_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
$morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', null, null, '', 1);
/*
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
// Project
if (isModEnabled('project'))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($permissiontoadd)
{
if ($action != 'classify')
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= ': '.$proj->getNomUrl();
} else {
$morehtmlref .= '';
}
}
}*/
$morehtmlref .= '</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass = "titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
print dol_get_fiche_end();
}
// End of page
llxFooter();
$db->close();

File diff suppressed because it is too large Load diff

View file

@ -2045,6 +2045,12 @@ class Propal extends CommonObject
$error++;
$this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'propale/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'propale/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@ -2474,6 +2480,7 @@ class Propal extends CommonObject
* @return int <0 if ko, >0 if ok
* @deprecated remise_percent is a deprecated field for object parent
*/
/*
public function set_remise_percent($user, $remise, $notrigger = 0)
{
// phpcs:enable
@ -2526,7 +2533,7 @@ class Propal extends CommonObject
return -1;
}
*/
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
@ -3153,6 +3160,7 @@ class Propal extends CommonObject
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
$res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive
if (!$res) {
$error++;
}
@ -3175,7 +3183,7 @@ class Propal extends CommonObject
}
}
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
$res = @dol_delete_dir_recursive($dir); // delete files physically + into ecm tables
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors[] = $this->error;
@ -4003,17 +4011,17 @@ class Propal extends CommonObject
if ($selected >= 0) {
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
if (property_exists($this, 'fk_project')) {
$return .= '<span class="info-box-ref"> | '.$this->fk_project.'</span>';
if (!empty($arraydata['projectlink'])) {
$return .= '<span class="info-box-ref"> | '.$arraydata['projectlink'].'</span>';
}
if (property_exists($this, 'author')) {
$return .= '<br><span class="info-box-label">'.$this->author.'</span>';
if (!empty($arraydata['authorlink'])) {
$return .= '<br><span class="info-box-label">'.$arraydata['authorlink'].'</span>';
}
if (property_exists($this, 'total_ht')) {
$return .='<br><span class="" >'.$langs->trans("AmountHT").' : </span><span class="info-box-label amount">'.price($this->total_ht).'</span>';
$return .='<br><span class="info-box-label amount" title="'.$langs->trans("AmountHT").'">'.price($this->total_ht).'</span>';
}
if (method_exists($this, 'getLibStatut')) {
$return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).'</div>';
$return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
}
$return .= '</div>';
$return .= '</div>';

View file

@ -317,85 +317,86 @@ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Do we click on 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
$search_categ = '';
$search_user = '';
$search_sale = '';
$search_ref = '';
$search_refcustomer = '';
$search_refproject = '';
$search_project = '';
$search_societe = '';
$search_societe_alias = '';
$search_montant_ht = '';
$search_montant_vat = '';
$search_montant_ttc = '';
$search_warehouse = '';
$search_multicurrency_code = '';
$search_multicurrency_tx = '';
$search_multicurrency_montant_ht = '';
$search_multicurrency_montant_vat = '';
$search_multicurrency_montant_ttc = '';
$search_login = '';
$search_product_category = '';
$search_town = '';
$search_zip = "";
$search_state = "";
$search_type = '';
$search_country = '';
$search_type_thirdparty = '';
$search_date_startday = '';
$search_date_startmonth = '';
$search_date_startyear = '';
$search_date_endday = '';
$search_date_endmonth = '';
$search_date_endyear = '';
$search_date_start = '';
$search_date_end = '';
$search_date_end_startday = '';
$search_date_end_startmonth = '';
$search_date_end_startyear = '';
$search_date_end_endday = '';
$search_date_end_endmonth = '';
$search_date_end_endyear = '';
$search_date_end_start = '';
$search_date_end_end = '';
$search_date_delivery_startday = '';
$search_date_delivery_startmonth = '';
$search_date_delivery_startyear = '';
$search_date_delivery_endday = '';
$search_date_delivery_endmonth = '';
$search_date_delivery_endyear = '';
$search_date_delivery_start = '';
$search_date_delivery_end = '';
$search_availability = '';
$search_status = '';
$object_statut = '';
$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;
}
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
$search_categ = '';
$search_user = '';
$search_sale = '';
$search_ref = '';
$search_refcustomer = '';
$search_refproject = '';
$search_project = '';
$search_societe = '';
$search_societe_alias = '';
$search_montant_ht = '';
$search_montant_vat = '';
$search_montant_ttc = '';
$search_warehouse = '';
$search_multicurrency_code = '';
$search_multicurrency_tx = '';
$search_multicurrency_montant_ht = '';
$search_multicurrency_montant_vat = '';
$search_multicurrency_montant_ttc = '';
$search_login = '';
$search_product_category = '';
$search_town = '';
$search_zip = "";
$search_state = "";
$search_type = '';
$search_country = '';
$search_type_thirdparty = '';
$search_date_startday = '';
$search_date_startmonth = '';
$search_date_startyear = '';
$search_date_endday = '';
$search_date_endmonth = '';
$search_date_endyear = '';
$search_date_start = '';
$search_date_end = '';
$search_date_end_startday = '';
$search_date_end_startmonth = '';
$search_date_end_startyear = '';
$search_date_end_endday = '';
$search_date_end_endmonth = '';
$search_date_end_endyear = '';
$search_date_end_start = '';
$search_date_end_end = '';
$search_date_delivery_startday = '';
$search_date_delivery_startmonth = '';
$search_date_delivery_startyear = '';
$search_date_delivery_endday = '';
$search_date_delivery_endmonth = '';
$search_date_delivery_endyear = '';
$search_date_delivery_start = '';
$search_date_delivery_end = '';
$search_availability = '';
$search_status = '';
$object_statut = '';
$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 = '';
$toselect = array();
$search_array_options = array();
}
if ($object_statut != '') {
$search_status = $object_statut;
}
// Mass actions
$objectclass = 'Propal';
$objectlabel = 'Proposals';
$uploaddir = $conf->propal->multidir_output[$conf->entity];
@ -828,6 +829,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
$db->free($resql);
}
// Complete request and execute it with limit
$sql .= $db->order($sortfield, $sortorder);
$sql .= ', p.ref DESC';
if ($limit) {
@ -835,213 +837,216 @@ if ($limit) {
}
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
if ($resql) {
$objectstatic = new Propal($db);
$userstatic = new User($db);
if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
$title = $langs->trans('Proposals').' - '.$soc->name;
if (empty($search_societe)) {
$search_societe = $soc->name;
}
} else {
$title = $langs->trans('Proposals');
if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
$title = $langs->trans('Proposals').' - '.$soc->name;
if (empty($search_societe)) {
$search_societe = $soc->name;
}
} else {
$title = $langs->trans('Proposals');
}
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
$obj = $db->fetch_object($resql);
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/comm/propal/card.php?id='.$id);
exit;
}
header("Location: ".DOL_URL_ROOT.'/comm/propal/card.php?id='.$id);
exit;
}
$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
llxHeader('', $title, $help_url);
$param = '&search_status='.urlencode($search_status);
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='.((int) $limit);
}
if ($sall) {
$param .= '&sall='.urlencode($sall);
}
if ($search_date_startday) {
$param .= '&search_date_startday='.urlencode($search_date_startday);
}
if ($search_date_startmonth) {
$param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
}
if ($search_date_startyear) {
$param .= '&search_date_startyear='.urlencode($search_date_startyear);
}
if ($search_date_endday) {
$param .= '&search_date_endday='.urlencode($search_date_endday);
}
if ($search_date_endmonth) {
$param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
}
if ($search_date_endyear) {
$param .= '&search_date_endyear='.urlencode($search_date_endyear);
}
if ($search_date_end_startday) {
$param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
}
if ($search_date_end_startmonth) {
$param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
}
if ($search_date_end_startyear) {
$param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
}
if ($search_date_end_endday) {
$param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
}
if ($search_date_end_endmonth) {
$param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
}
if ($search_date_end_endyear) {
$param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
}
if ($search_date_delivery_startday) {
$param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
}
if ($search_date_delivery_startmonth) {
$param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
}
if ($search_date_delivery_startyear) {
$param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
}
if ($search_date_delivery_endday) {
$param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
}
if ($search_date_delivery_endmonth) {
$param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
}
if ($search_date_delivery_endyear) {
$param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_refcustomer) {
$param .= '&search_refcustomer='.urlencode($search_refcustomer);
}
if ($search_refproject) {
$param .= '&search_refproject='.urlencode($search_refproject);
}
if ($search_societe) {
$param .= '&search_societe='.urlencode($search_societe);
}
if ($search_societe_alias) {
$param .= '&search_societe_alias='.urlencode($search_societe_alias);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
}
if ($search_montant_ht) {
$param .= '&search_montant_ht='.urlencode($search_montant_ht);
}
if ($search_multicurrency_code != '') {
$param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
}
if ($search_multicurrency_tx != '') {
$param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
}
if ($search_multicurrency_montant_ht != '') {
$param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
}
if ($search_multicurrency_montant_vat != '') {
$param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
}
if ($search_multicurrency_montant_ttc != '') {
$param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
}
if ($search_login) {
$param .= '&search_login='.urlencode($search_login);
}
if ($search_town) {
$param .= '&search_town='.urlencode($search_town);
}
if ($search_zip) {
$param .= '&search_zip='.urlencode($search_zip);
}
if ($socid > 0) {
$param .= '&socid='.urlencode($socid);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_categ_cus > 0) {
$param .= '&search_categ_cus='.urlencode($search_categ_cus);
}
if ($search_product_category != '') {
$param .= '&search_product_category='.urlencode($search_product_category);
}
if ($search_fk_cond_reglement > 0) {
$param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
}
if ($search_fk_shipping_method > 0) {
$param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
}
if ($search_fk_input_reason > 0) {
$param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason);
}
if ($search_fk_mode_reglement > 0) {
$param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
}
if ($search_type_thirdparty > 0) {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
}
if ($search_town) {
$param .= '&search_town='.urlencode($search_town);
}
if ($search_zip) {
$param .= '&search_zip='.urlencode($search_zip);
}
if ($search_state) {
$param .= '&search_state='.urlencode($search_state);
}
if ($search_town) {
$param .= '&search_town='.urlencode($search_town);
}
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);
}
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='.((int) $limit);
}
if ($sall) {
$param .= '&sall='.urlencode($sall);
}
if ($search_date_startday) {
$param .= '&search_date_startday='.urlencode($search_date_startday);
}
if ($search_date_startmonth) {
$param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
}
if ($search_date_startyear) {
$param .= '&search_date_startyear='.urlencode($search_date_startyear);
}
if ($search_date_endday) {
$param .= '&search_date_endday='.urlencode($search_date_endday);
}
if ($search_date_endmonth) {
$param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
}
if ($search_date_endyear) {
$param .= '&search_date_endyear='.urlencode($search_date_endyear);
}
if ($search_date_end_startday) {
$param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
}
if ($search_date_end_startmonth) {
$param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
}
if ($search_date_end_startyear) {
$param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
}
if ($search_date_end_endday) {
$param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
}
if ($search_date_end_endmonth) {
$param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
}
if ($search_date_end_endyear) {
$param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
}
if ($search_date_delivery_startday) {
$param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
}
if ($search_date_delivery_startmonth) {
$param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
}
if ($search_date_delivery_startyear) {
$param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
}
if ($search_date_delivery_endday) {
$param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
}
if ($search_date_delivery_endmonth) {
$param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
}
if ($search_date_delivery_endyear) {
$param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_refcustomer) {
$param .= '&search_refcustomer='.urlencode($search_refcustomer);
}
if ($search_refproject) {
$param .= '&search_refproject='.urlencode($search_refproject);
}
if ($search_societe) {
$param .= '&search_societe='.urlencode($search_societe);
}
if ($search_societe_alias) {
$param .= '&search_societe_alias='.urlencode($search_societe_alias);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
}
if ($search_montant_ht) {
$param .= '&search_montant_ht='.urlencode($search_montant_ht);
}
if ($search_multicurrency_code != '') {
$param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
}
if ($search_multicurrency_tx != '') {
$param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
}
if ($search_multicurrency_montant_ht != '') {
$param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
}
if ($search_multicurrency_montant_vat != '') {
$param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
}
if ($search_multicurrency_montant_ttc != '') {
$param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
}
if ($search_login) {
$param .= '&search_login='.urlencode($search_login);
}
if ($search_town) {
$param .= '&search_town='.urlencode($search_town);
}
if ($search_zip) {
$param .= '&search_zip='.urlencode($search_zip);
}
if ($socid > 0) {
$param .= '&socid='.urlencode($socid);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_categ_cus > 0) {
$param .= '&search_categ_cus='.urlencode($search_categ_cus);
}
if ($search_product_category != '') {
$param .= '&search_product_category='.urlencode($search_product_category);
}
if ($search_fk_cond_reglement > 0) {
$param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
}
if ($search_fk_shipping_method > 0) {
$param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
}
if ($search_fk_input_reason > 0) {
$param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason);
}
if ($search_fk_mode_reglement > 0) {
$param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
}
if ($search_type_thirdparty > 0) {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
}
if ($search_town) {
$param .= '&search_town='.urlencode($search_town);
}
if ($search_zip) {
$param .= '&search_zip='.urlencode($search_zip);
}
if ($search_state) {
$param .= '&search_state='.urlencode($search_state);
}
if ($search_town) {
$param .= '&search_town='.urlencode($search_town);
}
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';
@ -1481,120 +1486,159 @@ if ($resql) {
print '<tr class="liste_titre">';
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.ref']['checked'])) {
print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.ref_client']['checked'])) {
print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['pr.ref']['checked'])) {
print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['pr.title']['checked'])) {
print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['s.nom']['checked'])) {
print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['s.name_alias']['checked'])) {
print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['s.town']['checked'])) {
print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['s.zip']['checked'])) {
print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['state.nom']['checked'])) {
print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['country.code_iso']['checked'])) {
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['typent.code']['checked'])) {
print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.date']['checked'])) {
print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.fin_validite']['checked'])) {
print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.date_livraison']['checked'])) {
print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.date_signature']['checked'])) {
print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['ava.rowid']['checked'])) {
print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "p.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "p.fk_input_reason", "", $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.total_ht']['checked'])) {
print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.total_tva']['checked'])) {
print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.total_ttc']['checked'])) {
print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.total_invoiced']['checked'])) {
print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['u.login']['checked'])) {
print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'class="center"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['sale_representative']['checked'])) {
print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['total_pa']['checked'])) {
print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['total_margin']['checked'])) {
print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['total_margin_rate']['checked'])) {
print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['total_mark_rate']['checked'])) {
print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -1612,30 +1656,38 @@ if ($resql) {
print $hookmanager->resPrint;
if (!empty($arrayfields['p.datec']['checked'])) {
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.tms']['checked'])) {
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.date_cloture']['checked'])) {
print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.note_public']['checked'])) {
print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.note_private']['checked'])) {
print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
$totalarray['nbfield']++;
}
print '</tr>'."\n";
$now = dol_now();
$i = 0;
// Loop on record
// --------------------------------------------------------------------
$typenArray = null;
$now = dol_now();
$with_margin_info = false;
if (isModEnabled('margin') && (
@ -1650,13 +1702,16 @@ if ($resql) {
$total_ht = 0;
$total_margin = 0;
$i = 0;
$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
}
$objectstatic->id = $obj->rowid;
$objectstatic->ref = $obj->ref;
@ -1721,9 +1776,8 @@ if ($resql) {
}
// Output Kanban
$userstatic->fetch($obj->fk_user_author);
$objectstatic->author = $userstatic->getNomUrl(1);
$objectstatic->fk_project = $projectstatic->getNomUrl(1);
print $objectstatic->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
$arrayofparams = array('selected' => in_array($object->id, $arrayofselected), 'authorlink' => $userstatic->getNomUrl(-2), 'projectlink' => $projectstatic->getNomUrl(2));
print $objectstatic->getKanbanView('', $arrayofparams);
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
@ -2326,24 +2380,26 @@ if ($resql) {
print '</form>'."\n";
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction;
$genallowed = $permissiontoread;
$delallowed = $permissiontoadd;
print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction;
$genallowed = $user->hasRight('propal', 'lire');
$delallowed = $user->hasRight('propal', 'creer');
print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
} else {
dol_print_error($db);
}
// End of page
llxFooter();
$db->close();
// End of page
llxFooter();
$db->close();

File diff suppressed because it is too large Load diff

View file

@ -286,6 +286,7 @@ class Commande extends CommonOrder
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')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
@ -569,6 +570,12 @@ class Commande extends CommonOrder
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'commande/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@ -2344,7 +2351,7 @@ class Commande extends CommonOrder
*
* TODO FONCTION NON FINIE A FINIR
*/
public function stock_array($filtre_statut = self::STATUS_CANCELED)
/*public function stock_array($filtre_statut = self::STATUS_CANCELED)
{
// phpcs:enable
$this->stocks = array();
@ -2372,7 +2379,7 @@ class Commande extends CommonOrder
}
}
return 0;
}
}*/
/**
* Delete an order line
@ -3500,6 +3507,7 @@ class Commande extends CommonOrder
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
$res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive
if (!$res) {
$error++;
}

View file

@ -472,7 +472,7 @@ if (empty($reshook)) {
$array_options = $lines[$i]->array_options;
}
$objecttmp->context['createfromclone'];
$objecttmp->context['createfromclone'] = 'createfromclone';
$rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
//there may already be rows from previous orders
@ -718,9 +718,9 @@ if ($action == 'shipped' && $permissiontoadd) {
if ($objecttmp->fetch($checked)) {
if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
if ($objecttmp->cloture($user)) {
setEventMessages($langs->trans('PassedInClosedStatus', $objecttmp->ref), null, 'mesgs');
setEventMessages($langs->trans('StatusOrderDelivered', $objecttmp->ref), null, 'mesgs');
} else {
setEventMessages($langs->trans('CantBeClosed'), null, 'errors');
setEventMessages($langs->trans('ErrorOrderStatusCantBeSetToDelivered'), null, 'errors');
$error++;
}
} else {

View file

@ -11,7 +11,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016-2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2021-2023 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
@ -48,6 +48,11 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (isModEnabled('categorie')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products'));
@ -73,7 +78,16 @@ $search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_mo
$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int'));
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int'));
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int'));
$search_product_category = GETPOST('search_product_category', 'int');
if (isModEnabled('categorie')) {
$search_product_category_array = GETPOST("search_category_".Categorie::TYPE_PRODUCT."_list", "array");
$searchCategoryProductOperator = 0;
if (GETPOSTISSET('formfilteraction')) {
$searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
$searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
}
}
// Détail commande
$search_id = GETPOST('search_id', 'alpha');
@ -159,7 +173,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
$fieldstosearchall = array(
'c.ref'=>'Ref',
'c.ref_client'=>'RefCustomerOrder',
'pd.description'=>'Description',
'cdet.description'=>'Description',
's.nom'=>"ThirdParty",
's.name_alias'=>"AliasNameShort",
's.zip'=>"Zip",
@ -257,7 +271,8 @@ if (empty($reshook)) {
$search_categ = '';
$search_user = '';
$search_sale = '';
$search_product_category = '';
$search_product_category_array = array();
$searchCategoryProductOperator = 0;
$search_id = '';
$search_refProduct = '';
$search_descProduct = '';
@ -404,12 +419,6 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as pr ON pr.rowid=cdet.fk_product'
if (!empty($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."commande_extrafields as ef on (c.rowid = ef.fk_object)";
}
if ($sall || $search_product_category > 0) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande';
}
if ($search_product_category > 0) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid';
@ -421,7 +430,6 @@ if ($search_user > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
}
// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
@ -440,9 +448,6 @@ if (!empty($productonly)) {
if (!empty($disablelinefree)) {
$sql .= " AND cdet.fk_product IS NOT NULL";
}
if ($search_product_category > 0) {
$sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
}
if ($socid > 0) {
$sql .= ' AND s.rowid = '.((int) $socid);
}
@ -592,8 +597,39 @@ if ($search_fk_input_reason > 0) {
$sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
}
// Search for tag/category ($searchCategoryProductList is an array of ID)
$searchCategoryProductList = $search_product_category_array;
if (!empty($searchCategoryProductList)) {
$searchCategoryProjectSqlList = array();
$listofcategoryid = '';
foreach ($searchCategoryProductList as $searchCategoryProject) {
if (intval($searchCategoryProject) == -2) {
$searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product)";
} elseif (intval($searchCategoryProject) > 0) {
if ($searchCategoryProductOperator == 0) {
$searchCategoryProjectSqlList[] = " EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product AND cp.fk_categorie = ".((int) $searchCategoryProject).")";
} else {
$listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
}
}
}
if ($listofcategoryid) {
$searchCategoryProjectSqlList[] = " EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product AND cp.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
}
if ($searchCategoryProductOperator == 1) {
if (!empty($searchCategoryProjectSqlList)) {
$sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
}
} else {
if (!empty($searchCategoryProjectSqlList)) {
$sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
}
}
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
@ -782,8 +818,10 @@ if ($resql) {
if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
}
if ($search_product_category != '') {
$param .= '&search_product_category='.urlencode($search_product_category);
if (!empty($search_product_category_array)) {
foreach ($search_product_category_array as $tmpval) {
$param .= '&search_categegory_product_list[]='.urlencode($tmpval);
}
}
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$param .= '&search_categ_cus='.urlencode($search_categ_cus);
@ -894,14 +932,10 @@ if ($resql) {
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
$moreforfilter .= '</div>';
}
// If the user can view prospects other than his'
// Filter on categories
if (isModEnabled("categorie") && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('IncludingProductWithTag');
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
$moreforfilter .= '</div>';
$formcategory = new FormCategory($db);
$moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $search_product_category_array, 'minwidth300imp minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
}
if (isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';

View file

@ -581,9 +581,11 @@ if ($action == 'create') {
}
if (isModEnabled('paymentbybanktransfer')) {
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>';
print '</td></tr>';
if ($mysoc->isInEEC()) {
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>';
print '</td></tr>';
}
}
print '</table>';
print '<hr>';
@ -830,15 +832,17 @@ if ($action == 'create') {
print '</tr>';
}
// TODO ICS is not used with bank transfer !
if (isModEnabled('paymentbybanktransfer')) {
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>';
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td><td>';
print (empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes"));
print "</td></tr>\n";
if (getDolGlobalString("SEPA_USE_IDS")) { // ICS is not used with bank transfer !
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>';
}
if ($mysoc->isInEEC()) {
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td><td>';
print (empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes"));
print "</td></tr>\n";
}
}
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td><td>';
@ -1123,14 +1127,14 @@ if ($action == 'create') {
// IBAN
print '<tr><td>';
$tooltip = $langs->trans("Example").':<br>CH93 0076 2011 6238 5295 7<br>LT12 1000 0111 0100 1000<br>FR14 2004 1010 0505 0001 3M02 606<br>LU28 0019 4006 4475 0000<br>DE89 3704 0044 0532 0130 00';
print $form->textwithpicto($langs->trans($ibankey), $tooltip);
print $form->textwithpicto($langs->trans($ibankey), $tooltip, 1, 'help', '', 0, 3, 'iban');
print '</td>';
print '<td><input class="minwidth300 maxwidth200onsmartphone" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOSTISSET('iban') ? GETPOST('iban', 'alphanohtml') : $object->iban).'"></td></tr>';
// BIC
print '<tr><td>';
$tooltip = $langs->trans("Example").': LIABLT2XXXX';
print $form->textwithpicto($langs->trans($bickey), $tooltip);
print $form->textwithpicto($langs->trans($bickey), $tooltip, 1, 'help', '', 0, 3, 'bic');
print '</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alphanohtml') : $object->bic).'"></td></tr>';
@ -1166,12 +1170,15 @@ if ($action == 'create') {
}
if (isModEnabled('paymentbybanktransfer')) {
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>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>';
print '</td></tr>';
if (getDolGlobalString("SEPA_USE_IDS")) { // ICS is not used with bank transfer !
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>';
}
if ($mysoc->isInEEC()) {
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>';
print '</td></tr>';
}
}
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';

View file

@ -278,7 +278,6 @@ class Account extends CommonObject
public $ics_transfer;
/**
* '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')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
@ -1568,11 +1567,11 @@ class Account extends CommonObject
// Call functions to check BAN
if (!checkIbanForAccount($this)) {
$error++;
$this->error_message = 'IBANNotValid';
$this->error = 'IBANNotValid';
}
if (!checkSwiftForAccount($this)) {
$error++;
$this->error_message = 'SwiftNotValid';
$this->error = 'SwiftNotValid';
}
if (! $error) {
@ -2014,6 +2013,10 @@ class AccountLine extends CommonObjectLine
public $note;
/**
* User author of the rapprochement.
*/
public $user_rappro;
/**

View file

@ -747,9 +747,9 @@ class PaymentVarious extends CommonObject
$this->id = $obj->rowid;
$this->user_creation = $obj->fk_user_author;
$this->user_modif = $obj->fk_user_modif;
$this->user_modification_id = $obj->fk_user_modif;
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modif = $this->db->jdate($obj->tms);
$this->date_modification = $this->db->jdate($obj->tms);
}
$this->db->free($result);
} else {

View file

@ -201,7 +201,7 @@ if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($n
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj && $obj->rowid) {
setEventMessages('ErrorThisBankReceiptIsAlreadyUsed', null, 'errors');
setEventMessages('ErrorBankReceiptAlreadyExists', null, 'errors');
$error++;
}
} else {
@ -371,7 +371,7 @@ if (empty($numref)) {
} else {
print '<input type="hidden" name="oldbankreceipt" value="'.$objp->numr.'">';
print '<input type="text" name="newbankreceipt" value="'.$objp->numr.'">';
print '<input type="submit" class="button smallpaddingimp" name="actionnewbankreceipt" value="'.$langs->trans("Rename").'">';
print '<input type="submit" class="button smallpaddingimp" name="actionnewbankreceipt" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print '</td>';

View file

@ -9,6 +9,7 @@
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2023 Nick Fragoulis
*
* 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
@ -203,25 +204,31 @@ if (empty($reshook)) {
}
if (!$error) {
$object->title = GETPOST('title', 'alphanohtml');
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
$object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
$object->subtype = GETPOST('subtype');
$object->title = GETPOST('title', 'alphanohtml');
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
$object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOST('auto_validate', 'int');
$object->generate_pdf = GETPOST('generate_pdf', 'int');
$object->fk_project = $projectid;
$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOST('auto_validate', 'int');
$object->generate_pdf = GETPOST('generate_pdf', 'int');
$object->fk_project = $projectid;
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
$object->date_when = $date_next_execution;
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
$error++;
}
// Get first contract linked to invoice used to generate template (facid is id of source invoice)
if (GETPOST('facid', 'int') > 0) {
$srcObject = new Facture($db);
@ -996,6 +1003,13 @@ if ($action == 'create') {
print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1, 'customer').'</td>';
print '</tr>';
// Invoice subtype
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
print "<tr><td>".$langs->trans("InvoiceSubtype")."</td><td>";
print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $object->subtype, 'subtype', -1, 0, 0, '');
print "</td></tr>";
}
$note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $object->note_public;
$note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $object->note_private;
@ -1023,28 +1037,6 @@ if ($action == 'create') {
}
$htmltext .= '</i>';
// Public note
print '<tr>';
print '<td class="tdtop">';
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
print '</td>';
print '<td>';
$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">';
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
print '</td>';
print '<td>';
$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);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>';
}
// Author
print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
@ -1068,6 +1060,18 @@ if ($action == 'create') {
print "</td></tr>";
}
//extrafields
$draft = new Facture($db);
$draft->fetch(GETPOST('facid', 'int'));
$extralabels = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
if ($draft->fetch_optionals() > 0) {
$object->array_options = array_merge($object->array_options, $draft->array_options);
}
print $object->showOptionals($extrafields, 'create', $parameters);
// Project
if (isModEnabled('project') && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
@ -1087,15 +1091,38 @@ if ($action == 'create') {
print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
print "</td></tr>";
// Public note
print '<tr>';
print '<td class="tdtop">';
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
print '</td>';
print '<td>';
$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">';
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
print '</td>';
print '<td>';
$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);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>';
}
print "</table>";
print dol_get_fiche_end();
// Autogeneration
$title = $langs->trans("Recurrence");
print load_fiche_titre(img_picto('', 'recurring', 'class="pictofixedwidth"').$title, '', '');
print '<span class="opacitymedium">'.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')).'</span><br><br>';
print dol_get_fiche_head(null, '', '', 0);
print '<table class="border centpercent">';
@ -1118,7 +1145,7 @@ if ($action == 'create') {
print "</td></tr>";
// Auto validate the invoice
print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>";
print "<tr><td>".$langs->trans("StatusOfAutoGeneratedInvoices")."</td><td>";
$select = array('0'=>$langs->trans('BillStatusDraft'), '1'=>$langs->trans('BillStatusValidated'));
print $form->selectarray('auto_validate', $select, GETPOST('auto_validate'));
print "</td></tr>";
@ -1266,14 +1293,26 @@ if ($action == 'create') {
print '<table class="border centpercent tableforfield">';
// Invoice subtype
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
print "<tr><td>".$langs->trans("InvoiceSubtype")."</td><td>";
if ($object->subtype > 0) {
print $object->getSubtypeLabel('facture_rec');
}
print "</td></tr>";
}
// Author
print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>';
print $author->getNomUrl(-1);
print "</td></tr>";
// Amount (excl. tax)
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
print '<td>'.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).'</td>';
print '</tr>';
// Amount tax
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).'</td>';
print '</tr>';
@ -1405,22 +1444,6 @@ if ($action == 'create') {
}
$htmltext .= '</i>';
// Note public
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'));
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';
// Note private
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'));
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';
// Bank Account
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
@ -1439,6 +1462,26 @@ if ($action == 'create') {
print "</td>";
print '</tr>';
// Extrafields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Note public
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'));
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';
// Note private
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'));
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';
// Model pdf
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
@ -1466,7 +1509,7 @@ if ($action == 'create') {
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2023 Nick Fragoulis
*
* 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
@ -86,6 +87,10 @@ class FactureRec extends CommonInvoice
*/
public $titre;
/**
* @var double
*/
public $multicurrency_subprice;
public $socid;
public $number;
public $date;
@ -170,7 +175,8 @@ class FactureRec extends CommonInvoice
'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>25),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
'subtype' =>array('type'=>'smallint(6)', 'label'=>'InvoiceSubtype', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>55, 'isameasure'=>1),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1),
@ -264,11 +270,12 @@ class FactureRec extends CommonInvoice
$facsrc = new Facture($this->db);
$result = $facsrc->fetch($facid);
if ($result > 0) {
$this->fk_soc = $facsrc->socid;
$this->socid = $facsrc->socid;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (";
$sql .= "titre";
$sql .= ", fk_soc";
$sql .= ", subtype";
$sql .= ", entity";
$sql .= ", datec";
$sql .= ", amount";
@ -296,7 +303,8 @@ class FactureRec extends CommonInvoice
$sql .= ", suspended";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'";
$sql .= ", ".((int) $this->fk_soc);
$sql .= ", ".((int) $this->socid);
$sql .= ", ".($this->subtype ? "'".$this->db->escape($this->subtype)."'" : "null");
$sql .= ", ".((int) $conf->entity);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0');
@ -492,8 +500,7 @@ class FactureRec extends CommonInvoice
$sql .= " localtax1 = ".((float) $this->total_localtax1).",";
$sql .= " localtax2 = ".((float) $this->total_localtax2).",";
$sql .= " total_ht = ".((float) $this->total_ht).",";
$sql .= " total_ttc = ".((float) $this->total_ttc).",";
$sql .= " remise_percent = ".((float) $this->remise_percent);
$sql .= " total_ttc = ".((float) $this->total_ttc);
// TODO Add missing fields
$sql .= " WHERE rowid = ".((int) $this->id);
@ -534,13 +541,15 @@ class FactureRec extends CommonInvoice
* @param int $rowid Id of object to load
* @param string $ref Reference of recurring invoice
* @param string $ref_ext External reference of invoice
* @param int $noextrafields 0=Default to load extrafields, 1=No extrafields
* @param int $nolines 0=Default to load lines, 1=No lines
* @return int >0 if OK, <0 if KO, 0 if not found
*/
public function fetch($rowid, $ref = '', $ref_ext = '')
public function fetch($rowid, $ref = '', $ref_ext = '', $noextrafields = 0, $nolines = 0)
{
dol_syslog('FactureRec::fetch', LOG_DEBUG);
$sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc';
$sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.subtype, f.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc';
$sql .= ', f.date_lim_reglement as dlr';
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
$sql .= ', f.modelpdf as model_pdf';
@ -578,6 +587,7 @@ class FactureRec extends CommonInvoice
$this->titre = $obj->title; // deprecated
$this->title = $obj->title;
$this->ref = $obj->title;
$this->subtype = $obj->subtype;
$this->suspended = $obj->suspended;
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva;
@ -620,16 +630,23 @@ class FactureRec extends CommonInvoice
// Retrieve all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
/*
* Lines
*/
$result = $this->fetch_lines();
if ($result < 0) {
$this->error = $this->db->lasterror();
return -3;
if (empty($noextrafields)) {
$result = $this->fetch_optionals();
if ($result < 0) {
$this->error = $this->db->lasterror();
return -4;
}
}
// Retreive lines
if (empty($nolines)) {
$result = $this->fetch_lines();
if ($result < 0) {
$this->error = $this->db->lasterror();
return -3;
}
}
return 1;
} else {
$this->error = 'Bill with id '.$rowid.' or ref '.$ref.' not found';
@ -1333,6 +1350,7 @@ class FactureRec extends CommonInvoice
$facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice
$facture->type = self::TYPE_STANDARD;
$facture->subtype = $facturerec->subtype;
$facture->statut = self::STATUS_DRAFT; // deprecated
$facture->status = self::STATUS_DRAFT;
$facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.

View file

@ -157,13 +157,6 @@ class Facture extends CommonInvoice
*/
public $ref_customer;
//public $remise_absolue;
/**
* @deprecated
*/
//public $remise_percent;
public $total_ht;
public $total_tva;
public $total_localtax1;
@ -255,6 +248,18 @@ class Facture extends CommonInvoice
*/
public $retained_warranty_fk_cond_reglement;
/**
* @var int availabilty ID
*/
public $availability_id;
public $date_closing;
/**
* @var int
*/
public $source;
/**
@ -2274,19 +2279,17 @@ class Facture extends CommonInvoice
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
// phpcs:enable
global $langs, $conf;
$this->lines = array();
$sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice, l.ref_ext,';
$sql .= ' l.situation_percent, l.fk_prev_id,';
$sql .= ' l.rang, l.special_code,';
$sql .= ' l.rang, l.special_code, l.batch, l.fk_warehouse,';
$sql .= ' l.date_start as date_start, l.date_end as date_end,';
$sql .= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
$sql .= ' l.fk_unit,';
$sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
$sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
$sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc, p.barcode as product_barcode';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
$sql .= ' WHERE l.fk_facture = '.((int) $this->id);
@ -2312,6 +2315,7 @@ class Facture extends CommonInvoice
$line->product_ref = $objp->product_ref; // Ref product
$line->libelle = $objp->product_label; // deprecated
$line->product_label = $objp->product_label; // Label product
$line->product_barcode = $objp->product_barcode; // Barcode number product
$line->product_desc = $objp->product_desc; // Description product
$line->fk_product_type = $objp->fk_product_type; // Type of product
$line->qty = $objp->qty;
@ -2350,6 +2354,9 @@ class Facture extends CommonInvoice
$line->fk_prev_id = $objp->fk_prev_id;
$line->fk_unit = $objp->fk_unit;
$line->batch = $objp->batch;
$line->fk_warehouse = $objp->fk_warehouse;
// Accountancy
$line->fk_accounting_account = $objp->fk_code_ventilation;
@ -2859,7 +2866,8 @@ class Facture extends CommonInvoice
$resql = $this->db->query($sql);
if ($resql) {
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
$this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
$this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
@ -3492,6 +3500,12 @@ class Facture extends CommonInvoice
$error++;
$this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'facture/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@ -5955,7 +5969,7 @@ class Facture extends CommonInvoice
}
if (method_exists($this, 'getLibStatut')) {
$alreadypaid = (empty($arraydata['alreadypaid']) ? 0 : $arraydata['alreadypaid']);
$return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3, $alreadypaid).'</div>';
$return .= '<br><div class="info-box-status">'.$this->getLibStatut(3, $alreadypaid).'</div>';
}
$return .= '</div>';
$return .= '</div>';
@ -6005,18 +6019,41 @@ class FactureLigne extends CommonInvoiceLine
public $marge_tx;
public $marque_tx;
/**
* @var int
*/
public $tva_npr;
public $remise_percent;
public $special_code; // Liste d'options non cumulabels:
// 1: frais de port
// 2: ecotaxe
// 3: ??
/**
* List of special options to define line:
* 1: shipment cost lines
* 2: ecotaxe
* 3: ??
* idofmodule: a meaning for the module
*/
public $special_code;
/**
* @var string To store the batch to consume in stock when using a POS module
*/
public $batch;
/**
* @var string To store the warehouse where to consume stock when using a POS module
*/
public $fk_warehouse;
public $origin;
public $origin_id;
/**
* @var integer Id in table llx_accounting_bookeeping to know accounting account for product line
*/
public $fk_code_ventilation = 0;
public $date_start;
public $date_end;

View file

@ -2131,8 +2131,12 @@ if ($num > 0) {
// Invoice Subtype
if (!empty($arrayfields['f.subtype']['checked'])) {
print '<td class="nowraponall tdoverflowmax300" title="'.$facturestatic->getSubtypeLabel().'">';
print $facturestatic->getSubtypeLabel('facture');
$labeltoshow = '';
if ($facturestatic->subtype > 0) {
$labeltoshow = $facturestatic->getSubtypeLabel('facture');
}
print '<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.'">';
print $labeltoshow;
print "</td>";
if (!$i) {
$totalarray['nbfield']++;

View file

@ -618,7 +618,7 @@ if ($object->id > 0) {
print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
if (!empty($bac->iban)) {
if ($bac->verif() <= 0) {
print img_warning('Error on default bank number for IBAN : '.$bac->error_message);
print img_warning('Error on default bank number for IBAN : '.$bac->error);
}
} else {
if ($numopen || ($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) {

View file

@ -49,6 +49,24 @@ class Localtax extends CommonObject
public $datev;
public $amount;
/**
* @var int
*/
public $accountid;
/**
* @var string
*/
public $fk_type;
public $paymenttype;
/**
* @var int
*/
public $rappro;
/**
* @var string local tax
*/
@ -216,7 +234,6 @@ class Localtax extends CommonObject
*/
public function fetch($id)
{
global $langs;
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.localtaxtype,";
@ -225,7 +242,7 @@ class Localtax extends CommonObject
$sql .= " t.datev,";
$sql .= " t.amount,";
$sql .= " t.label,";
$sql .= " t.note,";
$sql .= " t.note as note_private,";
$sql .= " t.fk_bank,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif,";
@ -250,7 +267,8 @@ class Localtax extends CommonObject
$this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->label = $obj->label;
$this->note = $obj->note;
$this->note = $obj->note_private;
$this->note_private = $obj->note_private;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
@ -515,7 +533,7 @@ class Localtax extends CommonObject
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
// Mise a jour fk_bank dans llx_localtax. On connait ainsi la ligne de localtax qui a g<>n<EFBFBD>r<EFBFBD> l'<27>criture bancaire
// Update fk_bank into llx_localtax so we know the line of localtax used to generate the bank entry.
if ($bank_line_id > 0) {
$this->update_fk_bank($bank_line_id);
} else {

View file

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->load("bills");
$langs->loadLangs(array("banks", "bills", "compta"));
$chid = GETPOST("id", 'int');
$action = GETPOST('action', 'aZ09');
@ -208,7 +208,8 @@ if ($action == 'create') {
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype") : $charge->paiementtype, "paiementtype");
print img_picto('', 'bank', 'class="pictofixedwidth"');
print $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype") : $charge->paiementtype, "paiementtype", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusxx', 1);
print "</td>\n";
print '</tr>';
@ -216,18 +217,20 @@ if ($action == 'create') {
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td>';
print img_picto('', 'bank_account', 'class="pictofixedwidth"');
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $charge->accountid, "accountid", 0, '', 2); // Show opend bank account list
print $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $charge->accountid, "accountid", 0, '', 2, '', 0, 'maxwidth500 widthcentpercentminusx', 1); // Show opend bank account list
print '</td></tr>';
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
if (empty($conf->dol_optimize_smallscreen)) {
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
}
print '</td>';
print '<td><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n";
print '<td><input name="num_payment" class="width100" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n";
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'">'.GETPOST('note', 'alphanohtml').'</textarea></td>';
print '<td class="tdtop"><textarea class="quatrevingpercent" name="note" wrap="soft" rows="'.ROWS_3.'">'.GETPOST('note', 'alphanohtml').'</textarea></td>';
print '</tr>';
print '</table>';
@ -240,6 +243,7 @@ if ($action == 'create') {
$num = 1;
$i = 0;
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("SocialContribution").'</td>';
@ -265,13 +269,13 @@ if ($action == 'create') {
print "<td align=\"center\"><b>!!!</b></td>\n";
}
print '<td class="right"><span class="amount">'.price($objp->amount)."</span></td>";
print '<td class="right nowraponall"><span class="amount">'.price($objp->amount)."</span></td>";
print '<td class="right"><span class="amount">'.price($sumpaid)."</span></td>";
print '<td class="right nowraponall"><span class="amount">'.price($sumpaid)."</span></td>";
print '<td class="right"><span class="amount">'.price($objp->amount - $sumpaid)."</span></td>";
print '<td class="right nowraponall"><span class="amount">'.price($objp->amount - $sumpaid)."</span></td>";
print '<td class="center">';
print '<td class="center nowraponall">';
if ($sumpaid < $objp->amount) {
$namef = "amount_".$objp->id;
$nameRemain = "remain_".$objp->id;
@ -304,6 +308,7 @@ if ($action == 'create') {
}
print "</table>";
print '</div>';
// Save payment button
print '<br><div class="center"><input type="checkbox" checked name="closepaidcontrib"> '.$langs->trans("ClosePaidContributionsAutomatically");

View file

@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'withdrawals'));
@ -65,6 +66,12 @@ if (prelevement_check_config('bank-transfer') < 0) {
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("PaymentByBankTransfer")), null, 'errors');
}
$thirdpartystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db);
$bprev = new BonPrelevement($db);
$salary = new Salary($db);
$user = new User($db);
$newcardbutton = '';
if ($usercancreate) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewPaymentByBankTransfer'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type=bank-transfer');
@ -76,129 +83,197 @@ print load_fiche_titre($langs->trans("SuppliersStandingOrdersArea"), $newcardbut
print '<div class="fichecenter"><div class="fichethirdleft">';
$thirdpartystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db);
$bprev = new BonPrelevement($db);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("NbOfInvoiceToPayByBankTransfer").'</td>';
print '<td class="right">';
print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0&type=bank-transfer">';
print $bprev->nbOfInvoiceToPay('bank-transfer');
print '</a>';
print '</td></tr>';
$totaltoshow = 0;
print '<tr class="oddeven"><td>'.$langs->trans("AmountToTransfer").'</td>';
if (isModEnabled('supplier_invoice')) {
print '<tr class="oddeven"><td>'.$langs->trans("NbOfInvoiceToPayByBankTransfer").'</td>';
print '<td class="right">';
print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0&type=bank-transfer">';
print $bprev->nbOfInvoiceToPay('bank-transfer');
print '</a>';
print '</td></tr>';
$totaltoshow += $bprev->SommeAPrelever('bank-transfer');
}
if (isModEnabled('salaries')) {
print '<tr class="oddeven"><td>'.$langs->trans("NbOfInvoiceToPayByBankTransferForSalaries").'</td>';
print '<td class="right">';
print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0&type=bank-transfer&sourcetype=salary">';
print $bprev->nbOfInvoiceToPay('bank-transfer', 'salary');
print '</a>';
print '</td></tr>';
$totaltoshow += $bprev->SommeAPrelever('bank-transfer', 'salary');
}
print '<tr class="oddeven"><td>'.$langs->trans("Total").'</td>';
print '<td class="right"><span class="amount nowraponall">';
print price($bprev->SommeAPrelever('bank-transfer'), '', '', 1, -1, -1, 'auto');
print price($totaltoshow, '', '', 1, -1, -1, 'auto');
print '</span></td></tr></table></div><br>';
/*
* Invoices waiting for withdraw
*/
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type, f.datef, f.date_lim_reglement,";
$sql .= " pfd.date_demande, pfd.amount,";
$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " AND f.total_ttc > 0";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
}
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="5">'.$langs->trans("SupplierInvoiceWaitingWithdraw").' <span class="opacitymedium">('.$num.')</span></th></tr>';
if ($num) {
while ($i < $num && $i < 20) {
$obj = $db->fetch_object($resql);
$invoicestatic->id = $obj->rowid;
$invoicestatic->ref = $obj->ref;
$invoicestatic->status = $obj->fk_statut;
$invoicestatic->statut = $obj->fk_statut; // For backward comaptibility
$invoicestatic->paye = $obj->paye;
$invoicestatic->type = $obj->type;
$invoicestatic->date = $db->jdate($obj->datef);
$invoicestatic->date_echeance = $db->jdate($obj->date_lim_reglement);
$invoicestatic->total_ttc = $obj->total_ttc;
$alreadypayed = $invoicestatic->getSommePaiement();
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
$thirdpartystatic->tva_intra = $obj->tva_intra;
$thirdpartystatic->siren = $obj->idprof1;
$thirdpartystatic->siret = $obj->idprof2;
$thirdpartystatic->ape = $obj->idprof3;
$thirdpartystatic->idprof1 = $obj->idprof1;
$thirdpartystatic->idprof2 = $obj->idprof2;
$thirdpartystatic->idprof3 = $obj->idprof3;
$thirdpartystatic->idprof4 = $obj->idprof4;
$thirdpartystatic->idprof5 = $obj->idprof5;
$thirdpartystatic->idprof6 = $obj->idprof6;
print '<tr class="oddeven"><td class="nowraponall">';
print $invoicestatic->getNomUrl(1, 'withdraw');
print '</td>';
print '<td class="tdoverflowmax150">';
print $thirdpartystatic->getNomUrl(1, 'supplier');
print '</td>';
print '<td class="right">';
print '<span class="amount">'.price($obj->amount).'</span>';
print '</td>';
print '<td class="right">';
print dol_print_date($db->jdate($obj->date_demande), 'day');
print '</td>';
print '<td class="right">';
print $invoicestatic->getLibStatut(3, $alreadypayed);
print '</td>';
print '</tr>';
$i++;
}
} else {
$titlefortab = $langs->transnoentitiesnoconv("BankTransfer");
print '<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans("NoSupplierInvoiceToWithdraw", $titlefortab, $titlefortab).'</span></td></tr>';
if (isModEnabled('supplier_invoice')) {
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type, f.datef, f.date_lim_reglement,";
$sql .= " pfd.date_demande, pfd.amount,";
$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " AND f.total_ttc > 0";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
}
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
$sqlForSalary = "SELECT * FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."prelevement_demande as pd";
$sqlForSalary .= " WHERE s.rowid = pd.fk_salary AND s.paye = 0 AND pd.traite = 0";
$sqlForSalary .= " AND s.entity IN (".getEntity('salary').")";
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="5">'.$langs->trans("SupplierInvoiceWaitingWithdraw").' <span class="opacitymedium">('.$num.')</span></th></tr>';
if ($num) {
while ($i < $num && $i < 20) {
$obj = $db->fetch_object($resql);
$invoicestatic->id = $obj->rowid;
$invoicestatic->ref = $obj->ref;
$invoicestatic->status = $obj->fk_statut;
$invoicestatic->statut = $obj->fk_statut; // For backward comaptibility
$invoicestatic->paye = $obj->paye;
$invoicestatic->type = $obj->type;
$invoicestatic->date = $db->jdate($obj->datef);
$invoicestatic->date_echeance = $db->jdate($obj->date_lim_reglement);
$invoicestatic->total_ttc = $obj->total_ttc;
$alreadypayed = $invoicestatic->getSommePaiement();
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
$thirdpartystatic->tva_intra = $obj->tva_intra;
$thirdpartystatic->idprof1 = $obj->idprof1;
$thirdpartystatic->idprof2 = $obj->idprof2;
$thirdpartystatic->idprof3 = $obj->idprof3;
$thirdpartystatic->idprof4 = $obj->idprof4;
$thirdpartystatic->idprof5 = $obj->idprof5;
$thirdpartystatic->idprof6 = $obj->idprof6;
print '<tr class="oddeven"><td class="nowraponall">';
print $invoicestatic->getNomUrl(1, 'withdraw');
print '</td>';
print '<td class="tdoverflowmax150">';
print $thirdpartystatic->getNomUrl(1, 'supplier');
print '</td>';
print '<td class="right">';
print '<span class="amount">'.price($obj->amount).'</span>';
print '</td>';
print '<td class="right">';
print dol_print_date($db->jdate($obj->date_demande), 'day');
print '</td>';
print '<td class="right">';
print $invoicestatic->getLibStatut(3, $alreadypayed);
print '</td>';
print '</tr>';
$i++;
}
} else {
$titlefortab = $langs->transnoentitiesnoconv("BankTransfer");
print '<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans("NoSupplierInvoiceToWithdraw", $titlefortab, $titlefortab).'</span></td></tr>';
}
print "</table></div><br>";
} else {
dol_print_error($db);
}
}
if (isModEnabled('salaries')) {
$resql2 = $db->query($sqlForSalary);
if ($resql2) {
$numRow = $db->num_rows($resql2);
$j = 0 ;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder rightpercent">';
print '<tr class="liste_titre">';
print '<th colspan="5">'.$langs->trans("SalaryInvoiceWaitingWithdraw").' <span class="opacitymedium">('.$numRow.')</span></th></tr>';
if ($numRow) {
while ($j < $numRow && $j<10) {
$objSalary = $db->fetch_object($resql2);
$user->fetch($objSalary->fk_user);
$salary->fetch($objSalary->fk_salary);
$alreadypayedS = $salary->getSommePaiement();
print '<tr class="oddeven"><td class="nowraponall">';
print $salary->getNomUrl(1);
print '</td>';
print '<td class="tdoverflowmax150">';
print $user->getNomUrl(-1);
print '</td>';
print '<td class="right">';
print '<span class="amount">'.price($objSalary->amount).'</span>';
print '</td>';
print '<td class="right" title="'.$langs->trans("DateRequest").'">';
print dol_print_date($db->jdate($objSalary->date_demande), 'day');
print '</td>';
print '<td class="right">';
print $salary->getLibStatut(3, $alreadypayedS);
print '</td>';
print '</tr>';
$j++;
}
} else {
$titlefortab = $langs->transnoentitiesnoconv("BankTransfer");
print '<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans("NoSalaryInvoiceToWithdraw", $titlefortab, $titlefortab).'</span></td></tr>';
}
print "</table></div><br>";
} else {
dol_print_error($db);
}
print "</table></div><br>";
} else {
dol_print_error($db);
}
print '</div><div class="fichetwothirdright">';
/*
* Withdraw receipts
*/

View file

@ -71,7 +71,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
$type = $object->type;
// chek if salary pl
$salaryBonPl = $object->checkIfSalaryBonPrelevement();
if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
@ -430,20 +431,27 @@ if ($id > 0 || $ref) {
/*
* Lines into withdraw request
*/
$sql = "SELECT pl.rowid, pl.statut, pl.amount,";
$sql .= " s.rowid as socid, s.nom as name";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
$sql .= " AND pl.fk_prelevement_bons = pb.rowid";
$sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
$sql .= " AND pl.fk_soc = s.rowid";
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
if ($salaryBonPl) {
$sql = "SELECT pl.rowid, pl.statut, pl.amount,pl.fk_user";
$sql .=" FROM llx_prelevement as p, llx_prelevement_lignes as pl, llx_salary as s";
$sql .= " WHERE pl.rowid = p.fk_prelevement_lignes";
$sql .= " AND p.fk_salary = s.rowid";
$sql .= " AND pl.fk_prelevement_bons = ".((int) $id);
} else {
$sql = "SELECT pl.rowid, pl.statut, pl.amount,";
$sql .= " s.rowid as socid, s.nom as name";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
$sql .= " AND pl.fk_prelevement_bons = pb.rowid";
$sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
$sql .= " AND pl.fk_soc = s.rowid";
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
$sql .= $db->order($sortfield, $sortorder);
}
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
@ -491,7 +499,7 @@ if ($id > 0 || $ref) {
print '<table class="noborder liste centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder);
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
print_liste_field_titre((!$salaryBonPl ? "ThirdParty" : "Employee"), $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $urladd, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre('');
print "</tr>\n";
@ -509,11 +517,15 @@ if ($id > 0 || $ref) {
print $ligne->LibStatut($obj->statut, 2);
print '<span class="paddingleft">'.$obj->rowid.'</span>';
print '</a></td>';
$thirdparty = new Societe($db);
$thirdparty->fetch($obj->socid);
if (!$salaryBonPl) {
$thirdparty = new Societe($db);
$thirdparty->fetch($obj->socid);
} else {
$userSalary = new User($db);
$userSalary->fetch($obj->fk_user);
}
print '<td>';
print $thirdparty->getNomUrl(1);
print (!$salaryBonPl ? $thirdparty->getNomUrl(1) : $userSalary->getNomUrl(-1));
print "</td>\n";
print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";

View file

@ -28,13 +28,14 @@
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
@ -225,16 +226,18 @@ class BonPrelevement extends CommonObject
* @param string $number bank account number
* @param string $number_key number key of account number
* @param string $type 'debit-order' or 'bank-transfer'
* @param string $sourcetype 'salary' for invoice of salary
* @return int >0 if OK, <0 if KO
*/
public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type = 'debit-order')
public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type = 'debit-order', $sourcetype = '')
{
// phpcs:enable
$result = 0;
$line_id = 0;
// Add lines
$result = $this->addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key);
$result = $this->addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype);
if ($result == 0) {
if ($line_id > 0) {
@ -242,7 +245,11 @@ class BonPrelevement extends CommonObject
if ($type != 'bank-transfer') {
$sql .= "fk_facture";
} else {
$sql .= "fk_facture_fourn";
if (!empty($sourcetype)) {
$sql .= "fk_salary";
} else {
$sql .= "fk_facture_fourn";
}
}
$sql .= ",fk_prelevement_lignes";
$sql .= ") VALUES (";
@ -281,9 +288,10 @@ class BonPrelevement extends CommonObject
* @param string $code_guichet code of bank's office
* @param string $number bank account number
* @param string $number_key number key of account number
* @param string $sourcetype check if is salary invoice
* @return int >0 if OK, <0 if KO
*/
public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype = '')
{
$result = -1;
$concat = 0;
@ -295,7 +303,11 @@ class BonPrelevement extends CommonObject
$sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes";
$sql .= " WHERE fk_prelevement_bons = ".((int) $this->id);
$sql .= " AND fk_soc =".((int) $client_id);
if (empty($sourcetype)) {
$sql .= " AND fk_soc =".((int) $client_id);
} else {
$sql .= " AND fk_user =".((int) $client_id);
}
$sql .= " AND code_banque = '".$this->db->escape($code_banque)."'";
$sql .= " AND code_guichet = '".$this->db->escape($code_guichet)."'";
$sql .= " AND number = '".$this->db->escape($number)."'";
@ -319,17 +331,18 @@ class BonPrelevement extends CommonObject
$sql .= ", code_guichet";
$sql .= ", number";
$sql .= ", cle_rib";
$sql .= (!empty($sourcetype) ? ", fk_user" : "");
$sql .= ") VALUES (";
$sql .= $this->id;
$sql .= ", ".((int) $client_id);
$sql .= ", ".(empty($sourcetype) ? ((int) $client_id) : 0);
$sql .= ", '".$this->db->escape($client_nom)."'";
$sql .= ", ".((float) price2num($amount));
$sql .= ", '".$this->db->escape($code_banque)."'";
$sql .= ", '".$this->db->escape($code_guichet)."'";
$sql .= ", '".$this->db->escape($number)."'";
$sql .= ", '".$this->db->escape($number_key)."'";
$sql .= (!empty($sourcetype) ? ", ". ((int) $client_id) : '');
$sql .= ")";
if ($this->db->query($sql)) {
$line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes");
$result = 0;
@ -676,17 +689,17 @@ class BonPrelevement extends CommonObject
*/
$sql = "SELECT ";
if ($this->type == 'bank-transfer') {
$sql .= " pf.fk_facture_fourn";
$sql .= " p.fk_facture_fourn";
} else {
$sql .= " pf.fk_facture";
$sql .= " p.fk_facture";
}
if ($amounts) {
$sql .= ", SUM(pl.amount)";
}
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."prelevement as pf";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " , ".MAIN_DB_PREFIX."prelevement as p";
$sql .= " WHERE p.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND p.rowid = ".((int) $this->id);
$sql .= " AND p.entity = ".((int) $conf->entity);
@ -730,33 +743,42 @@ class BonPrelevement extends CommonObject
* Returns amount waiting for direct debit payment or credit transfer payment
*
* @param string $mode 'direct-debit' or 'bank-transfer'
* @param string $type for type=salary
* @return double <O if KO, Total amount
*/
public function SommeAPrelever($mode = 'direct-debit')
public function SommeAPrelever($mode = 'direct-debit', $type = '')
{
// phpcs:enable
global $conf;
$sql = "SELECT sum(pd.amount) as nb";
if ($mode != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
if ($type !== 'salary') {
if ($mode != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
}
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s,";
}
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd";
$sql .= " WHERE f.entity IN (".getEntity('invoice').")";
$sql .= ($type !== 'salary' ? " WHERE f.entity IN (".getEntity('invoice').")" : " WHERE s.entity IN (".getEntity('salary').")");
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
$sql .= ($type !== 'salary' ? " AND f.fk_statut = ".Facture::STATUS_VALIDATED : " AND s.paye = ".Salary::STATUS_UNPAID);
}
if ($mode != 'bank-transfer') {
$sql .= " AND f.rowid = pd.fk_facture";
if ($type !== 'salary') {
if ($mode != 'bank-transfer') {
$sql .= " AND f.rowid = pd.fk_facture";
} else {
$sql .= " AND f.rowid = pd.fk_facture_fourn";
}
} else {
$sql .= " AND f.rowid = pd.fk_facture_fourn";
$sql .= " AND s.rowid = pd.fk_salary";
}
$sql .= " AND f.paye = 0";
$sql .= ($type !== 'salary' ? " AND f.paye = 0" : "");
$sql .= " AND pd.traite = 0";
$sql .= " AND pd.ext_payment_id IS NULL";
$sql .= " AND f.total_ttc > 0";
$sql .= ($type !== 'salary' ? " AND f.total_ttc > 0" : "");
$resql = $this->db->query($sql);
if ($resql) {
@ -778,11 +800,16 @@ class BonPrelevement extends CommonObject
* Get number of invoices waiting for payment
*
* @param string $mode 'direct-debit' or 'bank-transfer'
* @param string $type for salary invoice
* @return int <O if KO, number of invoices if OK
*/
public function nbOfInvoiceToPay($mode = 'direct-debit')
public function nbOfInvoiceToPay($mode = 'direct-debit', $type = '')
{
return $this->NbFactureAPrelever($mode);
if ($type === 'salary') {
return $this->NbFactureAPrelever($mode, 1);
} else {
return $this->NbFactureAPrelever($mode);
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -790,39 +817,60 @@ class BonPrelevement extends CommonObject
* Get number of invoices to pay
*
* @param string $type 'direct-debit' or 'bank-transfer'
* @param int $forsalary 0= for facture & facture_supplier, 1=for salary
* @return int <O if KO, number of invoices if OK
*/
public function NbFactureAPrelever($type = 'direct-debit')
public function NbFactureAPrelever($type = 'direct-debit', $forsalary = 0)
{
// phpcs:enable
global $conf;
$sql = "SELECT count(f.rowid) as nb";
if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
if ($forsalary == 1 ) {
$sql = "SELECT count(s.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql = "SELECT count(f.rowid) as nb";
if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
}
}
$sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pd";
$sql .= " WHERE f.entity IN (".getEntity('invoice').")";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
if ($type == 'bank-transfer') {
$sql .= " AND f.rowid = pd.fk_facture_fourn";
if ($forsalary == 1) {
$sql .= " WHERE s.entity IN (".getEntity('invoice').")";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND s.paye = 0";
}
} else {
$sql .= " AND f.rowid = pd.fk_facture";
$sql .= " WHERE f.entity IN (".getEntity('invoice').")";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
}
if ($forsalary == 1) {
$sql .= " AND s.rowid = pd.fk_salary";
} else {
if ($type == 'bank-transfer') {
$sql .= " AND f.rowid = pd.fk_facture_fourn";
} else {
$sql .= " AND f.rowid = pd.fk_facture";
}
}
$sql .= " AND pd.traite = 0";
$sql .= " AND pd.ext_payment_id IS NULL";
$sql .= " AND f.total_ttc > 0";
if (!$forsalary == 1) {
$sql .= " AND f.total_ttc > 0";
} else {
$sql .= " AND s.paye = 0";
}
dol_syslog(get_class($this)."::NbFactureAPrelever");
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
$this->db->free($resql);
return $obj->nb;
@ -897,7 +945,6 @@ class BonPrelevement extends CommonObject
$factures_result = array();
$factures_prev_id = array();
$factures_errors = array();
if (!$error) {
dol_syslog(__METHOD__." Read invoices for did=".((int) $did), LOG_DEBUG);
@ -909,36 +956,52 @@ class BonPrelevement extends CommonObject
}
$sql .= ", pd.code_banque, pd.code_guichet, pd.number, pd.cle_rib";
$sql .= ", pd.amount";
$sql .= ", s.nom as name";
$sql .= ", f.ref, sr.bic, sr.iban_prefix, sr.frstrecur";
if ($sourcetype != 'salary') {
$sql .= ", s.nom as name";
$sql .= ", f.ref, sr.bic, sr.iban_prefix, sr.frstrecur";
} else {
$sql .= ", CONCAT(s.firstname,' ',s.lastname) as name";
$sql .= ", f.ref, sr.bic, sr.iban_prefix, 'FRST' as frstrecur";
}
if ($sourcetype != 'salary') {
if ($type != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_demande as pd ON f.rowid = pd.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_facture";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_demande as pd ON f.rowid = pd.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_facture_fourn";
}
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_rib as sr ON s.rowid = sr.fk_soc AND sr.default_rib = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_rib as sr ON s.rowid = sr.fk_soc AND sr.default_rib = 1";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."salary as f";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_demande as pd ON f.rowid = pd.fk_salary";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as s ON s.rowid = f.fk_user";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user_rib as sr ON s.rowid = sr.fk_user";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_salary";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON s.rowid = f.fk_user";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here
}
if ($sourcetype != 'salary') {
if ($type != 'bank-transfer') {
$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
} else {
$sql .= " WHERE f.entity IN (".getEntity('supplier_invoice').')';
}
} else {
$sql .= " WHERE f.entity IN (".getEntity('salary').')';
}
$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
if ($sourcetype != 'salary') {
$sql .= " AND f.fk_statut = 1"; // Invoice validated
$sql .= " AND f.paye = 0";
$sql .= " AND f.total_ttc > 0";
} else {
//$sql .= " AND f.fk_statut = 1"; // Invoice validated
$sql .= " AND f.paye = 0";
$sql .= " AND f.amount > 0";
}
$sql .= " AND pd.traite = 0";
$sql .= " AND pd.ext_payment_id IS NULL";
$sql .= " AND sr.type = 'ban' ";
if ($sourcetype != 'salary') {
$sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too
}
if ($did > 0) {
$sql .= " AND pd.rowid = ".((int) $did);
}
@ -949,8 +1012,9 @@ class BonPrelevement extends CommonObject
$i = 0;
while ($i < $num) {
$row = $this->db->fetch_row($resql);
$row = $this->db->fetch_row($resql); // TODO Replace with fetch_object()
$factures[$i] = $row; // All fields
if ($row[7] == 0) {
$error++;
dol_syslog(__METHOD__." Read invoices/salary error Found a null amount", LOG_ERR);
@ -959,6 +1023,7 @@ class BonPrelevement extends CommonObject
}
$i++;
}
$this->db->free($resql);
dol_syslog(__METHOD__." Read invoices/salary, ".$i." invoices/salary to withdraw", LOG_DEBUG);
} else {
@ -970,10 +1035,14 @@ class BonPrelevement extends CommonObject
}
if (!$error) {
// Make some checks
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
$soc = new Societe($this->db);
$tmpsoc = new Societe($this->db);
$tmpuser = new User($this->db);
// Check BAN
$i = 0;
@ -1018,13 +1087,30 @@ class BonPrelevement extends CommonObject
//dol_syslog(__METHOD__."::RIB is ok", LOG_DEBUG);
} else {
if ($type != 'bank-transfer') {
$tmpsoc->id = $fac[2];
$tmpsoc->name = $fac[8];
$invoice_url = "<a href='".DOL_URL_ROOT.'/compta/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";
} else {
$invoice_url = "<a href='".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);
$this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);
$error++;
}
dol_syslog(__METHOD__ . " Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() " . $fac->fk_soc . " " . $soc->name, LOG_WARNING);
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $soc->getNomUrl(0);
$this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $soc->getNomUrl(0);
if ($type == 'bank-transfer' && $sourcetype != 'salary') {
$tmpsoc->id = $fac[2];
$tmpsoc->name = $fac[8];
$invoice_url = "<a href='".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);
$this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);
$error++;
}
if ($type == 'bank-transfer' && $sourcetype == 'salary') {
$tmpuser->id = $fac[2];
$tmpuser->firstname = $fac[8];
$salary_url = "<a href='".DOL_URL_ROOT.'/salaries/card.php?id='.$fac[0]."'>".$fac[0]."</a>";
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);
$this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);
$error++;
}
dol_syslog(__METHOD__ . " Check BAN Error on default bank number IBAN/BIC reported by verif(): " . join(', ', $fac), LOG_WARNING);
}
} else {
dol_syslog(__METHOD__ . " Check BAN Failed to read company", LOG_WARNING);
@ -1063,7 +1149,6 @@ class BonPrelevement extends CommonObject
print $langs->trans("ModeWarning"); // "Option for real mode was not set, we stop after this simulation\n";
}
}
if ($ok) {
/*
* We are in real mode.
@ -1128,6 +1213,8 @@ class BonPrelevement extends CommonObject
$sql .= ")";
$resql = $this->db->query($sql);
if ($resql) {
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
$this->id = $prev_id;
@ -1143,17 +1230,9 @@ class BonPrelevement extends CommonObject
}
if (!$error) {
/*
if ($type != 'bank-transfer') {
$fact = new Facture($this->db);
} else {
$fact = new FactureFournisseur($this->db);
}
*/
// Add lines for the bon
if (count($factures_prev) > 0) {
foreach ($factures_prev as $fac) { // Add a link in database for each invoice
foreach ($factures_prev as $fac) { // Add a link in database for each invoice ro salary
// Fetch invoice
/*
$result = $fact->fetch($fac[0]);
@ -1180,7 +1259,9 @@ class BonPrelevement extends CommonObject
* $fac[11] : IBAN
* $fac[12] : frstrcur
*/
$ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type);
$ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type, $sourcetype);
if ($ri <> 0) {
$error++;
}
@ -1227,18 +1308,14 @@ class BonPrelevement extends CommonObject
$this->raison_sociale = $account->proprio;
}
$this->factures = $factures_prev_id;
$this->context['factures_prev'] = $factures_prev;
// Generation of direct debit or credit transfer file $this->filename (May be a SEPA file for european countries)
// This also set the property $this->total with amount that is included into file
if ($sourcetype == 'salary') {
$userid = $this->context['factures_prev'][0][2];
$result = $this->generate($format, $executiondate, $type, $fk_bank_account, $userid);
} else {
$result = $this->generate($format, $executiondate, $type);
}
$result = $this->generate($format, $executiondate, $type, $fk_bank_account, $userid);
if ($result < 0) {
//var_dump($this->error);
//var_dump($this->invoice_in_error);
@ -1247,7 +1324,7 @@ class BonPrelevement extends CommonObject
}
dol_syslog(__METHOD__." Bank order file has been generated under filename ".$this->filename, LOG_DEBUG);
}
//var_dump($this->total);exit;
/*
* Update total defined after generation of file
@ -1257,8 +1334,8 @@ class BonPrelevement extends CommonObject
$sql .= " SET amount = ".price2num($this->total);
$sql .= " WHERE rowid = ".((int) $this->id);
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
dol_syslog(__METHOD__." Error update total: ".$this->db->error(), LOG_ERR);
@ -1281,7 +1358,7 @@ class BonPrelevement extends CommonObject
if (!$error) {
$this->db->commit();
return count($factures_prev);
return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error
} else {
$this->db->rollback();
return -1;
@ -1606,18 +1683,18 @@ class BonPrelevement extends CommonObject
$sql = "SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as reffac, pf.fk_facture as idfac,";
$sql .= " f.ref as reffac, p.fk_facture as idfac,";
$sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as pf,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as p,";
$sql .= " ".MAIN_DB_PREFIX."societe as soc,";
$sql .= " ".MAIN_DB_PREFIX."c_country as c,";
$sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
$sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND pl.rowid = p.fk_prelevement_lignes";
$sql .= " AND p.fk_facture = f.rowid";
$sql .= " AND f.fk_soc = soc.rowid";
$sql .= " AND soc.fk_pays = c.rowid";
$sql .= " AND rib.fk_soc = f.fk_soc";
@ -1721,11 +1798,11 @@ class BonPrelevement extends CommonObject
/*
* Section Creditor (sepa Crediteurs bloc lines)
*/
// add condition for traiting sourcetype TODO
if (!empty($user_dest)) {
$sql = "SELECT u.rowid as userId, c.code as country_code, CONCAT(u.firstname,' ',u.lastname) as nom,";
$sql .= " pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " s.rowid as idSalary,rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum";
$sql .= " s.ref as reffac, p.fk_salary as idfac,";
$sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, '' as rum, '' as date_rum";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."salary as s,";
@ -1742,18 +1819,18 @@ class BonPrelevement extends CommonObject
} else {
$sql = "SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as reffac, pf.fk_facture_fourn as idfac, f.ref_supplier as fac_ref_supplier,";
$sql .= " f.ref as reffac, f.ref_supplier as fac_ref_supplier, p.fk_facture_fourn as idfac,";
$sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as pf,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as p,";
$sql .= " ".MAIN_DB_PREFIX."societe as soc,";
$sql .= " ".MAIN_DB_PREFIX."c_country as c,";
$sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
$sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture_fourn = f.rowid";
$sql .= " AND pl.rowid = p.fk_prelevement_lignes";
$sql .= " AND p.fk_facture_fourn = f.rowid";
$sql .= " AND f.fk_soc = soc.rowid";
$sql .= " AND soc.fk_pays = c.rowid";
$sql .= " AND rib.fk_soc = f.fk_soc";
@ -1768,7 +1845,6 @@ class BonPrelevement extends CommonObject
$num = $this->db->num_rows($resql);
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
if (!empty($cachearraytotestduplicate[$obj->idfac])) {
$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
$this->invoice_in_error[$obj->idfac] = $this->error;
@ -1841,10 +1917,10 @@ class BonPrelevement extends CommonObject
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as pf";
$sql .= " ".MAIN_DB_PREFIX."prelevement as p";
$sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND pl.rowid = p.fk_prelevement_lignes";
$sql .= " AND p.fk_facture = f.rowid";
// Lines
$i = 0;
@ -1867,10 +1943,10 @@ class BonPrelevement extends CommonObject
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as pf";
$sql .= " ".MAIN_DB_PREFIX."prelevement as p";
$sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture_fourn = f.rowid";
$sql .= " AND pl.rowid = p.fk_prelevement_lignes";
$sql .= " AND p.fk_facture_fourn = f.rowid";
// Lines
$i = 0;
$resql = $this->db->query($sql);
@ -2009,8 +2085,8 @@ class BonPrelevement extends CommonObject
* @param string $row_cg pl.code_guichet AS cg, Not used for SEPA
* @param string $row_cc pl.number AS cc, Not used for SEPA
* @param string $row_somme pl.amount AS somme,
* @param string $row_ref Invoice ref (f.ref)
* @param string $row_idfac pf.fk_facture AS idfac,
* @param string $row_ref Invoice ref (f.ref) or Salary ref
* @param string $row_idfac p.fk_facture AS idfac or p.fk_facture_fourn or p.fk_salary,
* @param string $row_iban rib.iban_prefix AS iban,
* @param string $row_bic rib.bic AS bic,
* @param string $row_datec rib.datec,
@ -2085,7 +2161,7 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .= ' </DrctDbtTxInf>'.$CrLf;
return $XML_DEBITOR;
} else {
// SEPA Paiement Information of seller for Credit Transfer
// SEPA Payment Information of seller for Credit Transfer
$XML_CREDITOR = '';
$XML_CREDITOR .= ' <CdtTrfTxInf>'.$CrLf;
$XML_CREDITOR .= ' <PmtId>'.$CrLf;
@ -2333,8 +2409,8 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf;
$XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;
$XML_SEPA_INFO .= ' <Ctry>'.$country[1].'</Ctry>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS), ' ')).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), ' ')).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;
$XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/
$XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
@ -2399,8 +2475,8 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf;
$XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;
$XML_SEPA_INFO .= ' <Ctry>'.$country[1].'</Ctry>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS), ' ')).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), ' ')).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;
$XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/
$XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
@ -2647,4 +2723,38 @@ class BonPrelevement extends CommonObject
$return .= '</div>';
return $return;
}
/**
* Check if is bon prelevement for salary invoice
*
* @return int 1 if OK, O if K0
*/
public function checkIfSalaryBonPrelevement()
{
if (!empty($this->id)) {
$id = $this->id;
} else {
return 0;
}
if ($id) {
$sql = "SELECT COUNT(*) AS nb FROM ".MAIN_DB_PREFIX."prelevement_lignes";
$sql .= " WHERE fk_prelevement_bons = ".((int) $id);
$sql .= " AND fk_soc = 0";
$sql .= " AND fk_user IS NOT NULL";
$num = 0;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
$num = $obj->nb;
}
if ($num > 0) {
return 1;
}
} else {
dol_print_error($this->db);
}
return 0;
}
}

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
@ -31,6 +31,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -41,14 +42,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills'));
$type = GETPOST('type', 'aZ09');
// Get supervariables
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
$type = GETPOST('type', 'aZ09');
$sourcetype = GETPOST('sourcetype', 'aZ09');
$format = GETPOST('format', 'aZ09');
$id_bankaccount = GETPOST('id_bankaccount', 'int');
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
@ -69,10 +70,17 @@ if ($user->socid) {
}
if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
$permissiontoread = $user->hasRight('paymentbybanktransfer', 'read');
$permissiontocreate = $user->hasRight('paymentbybanktransfer', 'create');
} else {
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
$permissiontoread = $user->hasRight('prelevement', 'bons', 'lire');
$permissiontocreate = $user->hasRight('prelevement', 'bons', 'creer');
}
$error = 0;
$option = "";
$mesg = '';
@ -94,20 +102,20 @@ if ($reshook < 0) {
if (empty($reshook)) {
// Change customer bank information to withdraw
/*
if ($action == 'modify') {
for ($i = 1; $i < 9; $i++) {
dolibarr_set_const($db, GETPOST("nom".$i), GETPOST("value".$i), 'chaine', 0, '', $conf->entity);
}
}
if ($action == 'create') {
*/
if ($action == 'create' && $permissiontocreate) {
$default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
//var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit;
if ($id_bankaccount != getDolGlobalInt($default_account)) {
$res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default
}
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$bank = new Account($db);
$bank->fetch(getDolGlobalInt($default_account));
@ -115,6 +123,7 @@ if (empty($reshook)) {
/*if ((empty($bank->ics) && $type !== 'bank-transfer')
|| (empty($bank->ics_transfer) && $type === 'bank-transfer')
) {*/
if (empty($bank->ics) && $type !== 'bank-transfer') {
$errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}'));
setEventMessages($errormessage, null, 'errors');
@ -127,16 +136,43 @@ if (empty($reshook)) {
if (!$error) {
// getDolGlobalString('PRELEVEMENT_CODE_BANQUE') and getDolGlobalString('PRELEVEMENT_CODE_GUICHET') should be empty (we don't use them anymore)
$result = $bprev->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $mode, $format, $executiondate, 0, $type);
$result = $bprev->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $mode, $format, $executiondate, 0, $type, 0, 0, $sourcetype);
if ($result < 0) {
setEventMessages($bprev->error, $bprev->errors, 'errors');
} elseif ($result == 0) {
$mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
setEventMessages($mesg, null, 'errors');
$mesg .= '<br>'."\n";
foreach ($bprev->invoice_in_error as $key => $val) {
$mesg .= '<span class="warning">'.$val."</span><br>\n";
$mesg = '';
if ($bprev->error || !empty($bprev->errors)) {
setEventMessages($bprev->error, $bprev->errors, 'errors');
} else {
$langs->load("errors");
setEventMessages($langs->trans("ErrorsOnXLines", count($bprev->invoice_in_error)), null, 'warnings');
}
if (!empty($bprev->invoice_in_error)) {
foreach ($bprev->invoice_in_error as $key => $val) {
$mesg .= '<span class="warning">'.$val."</span><br>\n";
}
}
} elseif ($result == 0 || !empty($bprev->invoice_in_error)) {
$mesg = '';
if ($result == 0) {
if ($type != 'bank-transfer') {
$mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
}
if ($type == 'bank-transfer' && $sourcetype != 'salary') {
$mesg = $langs->trans("NoInvoiceCouldBeWithdrawedSupplier", $format);
}
if ($type == 'bank-transfer' && $sourcetype == 'salary') {
$mesg = $langs->trans("NoSalariesCouldBeWithdrawed", $format);
}
setEventMessages($mesg, null, 'errors');
}
if (!empty($bprev->invoice_in_error)) {
$mesg .= '<br>'."\n";
foreach ($bprev->invoice_in_error as $key => $val) {
$mesg .= '<span class="warning">'.$val."</span><br>\n";
}
}
} else {
if ($type != 'bank-transfer') {
@ -154,6 +190,7 @@ if (empty($reshook)) {
}
}
}
$objectclass = "BonPrelevement";
if ($type == 'bank-transfer') {
$uploaddir = $conf->paymentbybanktransfer->dir_output;
@ -203,12 +240,23 @@ if ($type == 'bank-transfer') {
llxHeader('', $title);
print load_fiche_titre($title);
print dol_get_fiche_head();
$head = bon_prelevement_prepare_head($bprev, $bprev->nbOfInvoiceToPay($type), $bprev->nbOfInvoiceToPay($type, 'salary'));
if ($type) {
print dol_get_fiche_head($head, (!GETPOSTISSET('sourcetype') ? 'invoice' : 'salary'), $langs->trans("Invoices"), -1, $bprev->picto);
} else {
print load_fiche_titre($title);
print dol_get_fiche_head();
}
$nb = $bprev->nbOfInvoiceToPay($type);
$pricetowithdraw = $bprev->SommeAPrelever($type);
if ($sourcetype != 'salary') {
$nb = $bprev->nbOfInvoiceToPay($type);
$pricetowithdraw = $bprev->SommeAPrelever($type);
} else {
$nb = $bprev->nbOfInvoiceToPay($type, 'salary');
$pricetowithdraw = $bprev->SommeAPrelever($type, 'salary');
}
if ($nb < 0) {
dol_print_error($bprev->error);
}
@ -218,6 +266,9 @@ $labeltoshow = $langs->trans("NbOfInvoiceToWithdraw");
if ($type == 'bank-transfer') {
$labeltoshow = $langs->trans("NbOfInvoiceToPayByBankTransfer");
}
if ($sourcetype == 'salary') {
$labeltoshow = $langs->trans("NbOfInvoiceToPayByBankTransferForSalaries");
}
print '<tr><td class="titlefield">'.$labeltoshow.'</td>';
print '<td class="nowraponall">';
@ -233,15 +284,14 @@ print '</tr>';
print '</table>';
print '</div>';
if ($mesg) {
print $mesg;
}
print '<div class="tabsAction">'."\n";
print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="action" value="create">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<input type="hidden" name="sourcetype" value="'.$sourcetype.'">';
if ($nb) {
if ($pricetowithdraw) {
$title = $langs->trans('BankToReceiveWithdraw').': ';
@ -328,42 +378,65 @@ if ($nb) {
print "</form>\n";
print "</div>\n";
print '</form>';
// Show errors or warnings
if ($mesg) {
print $mesg;
print '<br>';
}
print '<br>';
/*
* Invoices waiting for withdraw
*/
$sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
if ($type == 'bank-transfer') {
$sql .= " f.ref_supplier,";
}
$sql .= " pfd.rowid as request_row_id, pfd.date_demande, pfd.amount";
if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
if ($sourcetype != 'salary') {
$sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
if ($type == 'bank-transfer') {
$sql .= " f.ref_supplier,";
}
$sql .= " pd.rowid as request_row_id, pd.date_demande, pd.amount";
if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
//$sql .= " AND pd.amount > 0";
$sql .= " AND f.total_ttc > 0"; // Avoid credit notes
$sql .= " AND pd.traite = 0";
$sql .= " AND pd.ext_payment_id IS NULL";
if ($type == 'bank-transfer') {
$sql .= " AND pd.fk_facture_fourn = f.rowid";
} else {
$sql .= " AND pd.fk_facture = f.rowid";
}
if ($socid > 0) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
//$sql .= " AND pfd.amount > 0";
$sql .= " AND f.total_ttc > 0"; // Avoid credit notes
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
if ($type == 'bank-transfer') {
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
} else {
$sql .= " AND pfd.fk_facture = f.rowid";
}
if ($socid > 0) {
$sql .= " AND f.fk_soc = ".((int) $socid);
$sql = "SELECT s.ref, s.rowid, s.amount, CONCAT(u.lastname, ' ', u.firstname) as name, u.rowid as uid,";
$sql .= " pd.rowid as request_row_id, pd.date_demande, pd.amount";
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s,";
$sql .= " ".MAIN_DB_PREFIX."user as u,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd";
$sql .= " WHERE s.fk_user = u.rowid";
$sql .= " AND s.entity IN (".getEntity('salary').")";
/*if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND s.fk_statut = ".Facture::STATUS_VALIDATED;
}*/
$sql .= " AND s.amount > 0";
$sql .= " AND pd.traite = 0";
$sql .= " AND pd.ext_payment_id IS NULL";
$sql .= " AND s.rowid = pd.fk_salary AND s.paye = ".Salary::STATUS_UNPAID;
$sql .= " AND pd.traite = 0";
}
$nbtotalofrecords = '';
@ -404,16 +477,26 @@ if ($resql) {
if ($type != '') {
print '<input type="hidden" name="type" value="'.$type.'">';
}
$title = $langs->trans("InvoiceWaitingWithdraw");
if ($type == 'bank-transfer') {
$title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
$picto = 'bill';
if ($type =='bank-transfer') {
if ($sourcetype != 'salary') {
$title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
} else {
$title = $langs->trans("SalaryWaitingWithdraw");
$picto = 'salary';
}
}
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', $massactionbutton, $num, $nbtotalofrecords, $picto, 0, '', '', $limit);
$tradinvoice = "Invoice";
if ($type == 'bank-transfer') {
$tradinvoice = "SupplierInvoice";
if ($sourcetype != 'salary') {
$tradinvoice = "SupplierInvoice";
} else {
$tradinvoice = "RefSalary";
}
}
print '<div class="div-table-responsive-no-min">';
@ -425,14 +508,31 @@ if ($resql) {
print '<td align="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
}
}
// Ref invoice or salary
print '<td>'.$langs->trans($tradinvoice).'</td>';
if ($type == 'bank-transfer') {
// Ref supplier
if ($type == 'bank-transfer' && $sourcetype != 'salary') {
print '<td>'.$langs->trans("RefSupplier").'</td>';
}
print '<td>'.$langs->trans("ThirdParty").'</td>';
// Thirdparty or user
if ($sourcetype != 'salary') {
print '<td>'.$langs->trans("ThirdParty").'</td>';
} else {
print '<td>'.$langs->trans("Employee").'</td>';
}
// BAN
print '<td>'.$langs->trans("RIB").'</td>';
print '<td>'.$langs->trans("RUM").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
// RUM
if (empty($type) || $type == 'direc-debit') {
print '<td>'.$langs->trans("RUM").'</td>';
}
print '<td class="right">';
if ($sourcetype == 'salary') {
print $langs->trans("Amount");
} else {
print $langs->trans("AmountTTC");
}
print '</td>';
print '<td class="right">'.$langs->trans("DateRequest").'</td>';
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
@ -443,18 +543,29 @@ if ($resql) {
print '</tr>';
if ($num) {
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
if ($sourcetype != 'salary') {
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
} else {
require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
}
while ($i < $num && $i < $limit) {
$obj = $db->fetch_object($resql);
if ($sourcetype != 'salary') {
$bac = new CompanyBankAccount($db); // Must include the new in loop so the fetch is clean
$bac->fetch(0, $obj->socid);
$bac = new CompanyBankAccount($db); // Must include the new in loop so the fetch is clean
$bac->fetch(0, $obj->socid);
$invoicestatic->id = $obj->rowid;
$invoicestatic->ref = $obj->ref;
$invoicestatic->ref_supplier = $obj->ref_supplier;
$invoicestatic->id = $obj->rowid;
$invoicestatic->ref = $obj->ref;
$invoicestatic->ref_supplier = $obj->ref_supplier;
} else {
$bac = new UserBankAccount($db);
$bac->fetch(0, '', $obj->uid);
$salary = new Salary($db);
$salary->fetch($obj->rowid);
}
print '<tr class="oddeven">';
// Action column
@ -472,28 +583,39 @@ if ($resql) {
// Ref invoice
print '<td class="tdoverflowmax150">';
print $invoicestatic->getNomUrl(1, 'withdraw');
if ($sourcetype != 'salary') {
print $invoicestatic->getNomUrl(1, 'withdraw');
} else {
print $salary->getNomUrl(1, 'withdraw');
}
print '</td>';
if ($type == 'bank-transfer') {
if ($type == 'bank-transfer' && $sourcetype != 'salary') {
print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($invoicestatic->ref_supplier).'">';
print dol_escape_htmltag($invoicestatic->ref_supplier);
print '</td>';
}
// Thirdparty
print '<td class="tdoverflowmax100">';
$thirdpartystatic->fetch($obj->socid);
print $thirdpartystatic->getNomUrl(1, 'ban');
print '</td>';
if ($sourcetype != 'salary') {
print '<td class="tdoverflowmax100">';
$thirdpartystatic->fetch($obj->socid);
print $thirdpartystatic->getNomUrl(1, 'ban');
print '</td>';
} else {
print '<td class="tdoverflowmax100">';
$user->fetch($obj->uid);
print $user->getNomUrl(-1);
print '</td>';
}
// RIB
// BAN
print '<td>';
if ($bac->id > 0) {
if (!empty($bac->iban) || !empty($bac->bic)) {
print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
if ($bac->verif() <= 0) {
print img_warning('Error on default bank number for IBAN : '.$langs->trans($bac->error_message));
print img_warning('Error on default bank number for IBAN : '.$langs->trans($bac->error));
}
} else {
print img_warning($langs->trans("IBANNotDefined"));
@ -504,20 +626,23 @@ if ($resql) {
print '</td>';
// RUM
print '<td>';
$rumtoshow = $thirdpartystatic->display_rib('rum');
if ($rumtoshow) {
print $rumtoshow;
$format = $thirdpartystatic->display_rib('format');
if ($type != 'bank-transfer') {
if ($format) {
print ' ('.$format.')';
if (empty($type) || $type == 'direct-debit') {
print '<td>';
$rumtoshow = $thirdpartystatic->display_rib('rum');
if ($rumtoshow) {
print $rumtoshow;
$format = $thirdpartystatic->display_rib('format');
if ($type != 'bank-transfer') {
if ($format) {
print ' ('.$format.')';
}
}
} else {
print img_warning($langs->trans("NoBankAccountDefined"));
}
} else {
print img_warning($langs->trans("NoBankAccountDefined"));
print '</td>';
}
print '</td>';
// Amount
print '<td class="right amount">';
print price($obj->amount, 0, $langs, 0, 0, -1, $conf->currency);

View file

@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
@ -44,6 +45,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$type = GETPOST('type', 'aZ09');
$sourcetype = GETPOST('sourcetype', 'aZ');
$search_facture = GETPOST('search_facture', 'alpha');
$search_societe = GETPOST('search_societe', 'alpha');
@ -127,52 +129,79 @@ if ($type == 'bank-transfer') {
}
// List of requests
$sql = "SELECT f.ref, f.rowid, f.total_ttc,";
$sql .= " s.nom as name, s.rowid as socid,";
$sql .= " pfd.date_demande as date_demande, pfd.amount, pfd.fk_user_demande";
if ($type != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
if ($sourcetype != 'salary') {
$sql = "SELECT f.ref, f.rowid, f.total_ttc,";
$sql .= " s.nom as name, s.rowid as socid,";
$sql .= " pd.date_demande as date_demande, pd.amount, pd.fk_user_demande";
if ($type != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
if (!$status) {
$sql .= " AND pd.traite = 0";
}
$sql .= " AND pd.ext_payment_id IS NULL";
if ($status) {
$sql .= " AND pd.traite = ".((int) $status);
}
$sql .= " AND f.total_ttc > 0";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
if ($type != 'bank-transfer') {
$sql .= " AND pd.fk_facture = f.rowid";
} else {
$sql .= " AND pd.fk_facture_fourn = f.rowid";
}
if ($search_facture) {
$sql .= natural_search("f.ref", $search_facture);
}
if ($search_societe) {
$sql .= natural_search("s.nom", $search_societe);
}
$sql .= $db->order($sortfield, $sortorder);
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql = "SELECT s.rowid,s.amount as total_ttc, pd.amount,";
$sql .= " s.fk_user, pd.date_demande, pd.fk_salary, CONCAT(u.firstname,' ',u.lastname) as nom";
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."user as u,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd";
$sql .= " WHERE s.rowid = pd.fk_salary";
$sql .= " AND u.rowid = s.fk_user";
$sql .= " AND s.entity IN (".getEntity("salary").")";
/*if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND s.statut = ".Salary::STATUS_UNPAID;
}*/
if (!$status) {
$sql .= " AND pd.traite = 0";
}
$sql .= " AND pd.ext_payment_id IS NULL";
if ($status) {
$sql .= " AND pd.traite = ".((int) $status);
}
$sql .= " AND s.amount > 0";
$sql .= " AND s.paye = ".Salary::STATUS_UNPAID;
if ($search_facture) {
$sql .= natural_search("s.rowid", $search_facture);
}
if ($search_societe) {
$sql .= natural_search("CONCAT(u.firstname,' ',u.lastname)", $search_societe);
}
//print $sql;
}
$sql .= " ".MAIN_DB_PREFIX."societe as s,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
if (!$status) {
$sql .= " AND pfd.traite = 0";
}
$sql .= " AND pfd.ext_payment_id IS NULL";
if ($status) {
$sql .= " AND pfd.traite = ".((int) $status);
}
$sql .= " AND f.total_ttc > 0";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
if ($type != 'bank-transfer') {
$sql .= " AND pfd.fk_facture = f.rowid";
} else {
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
}
if ($search_facture) {
$sql .= natural_search("f.ref", $search_facture);
}
if ($search_societe) {
$sql .= natural_search("s.nom", $search_societe);
}
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
@ -204,8 +233,11 @@ $newcardbutton = '<a class="marginrightonly" href="'.DOL_URL_ROOT.'/compta/prele
if ($type == 'bank-transfer') {
$newcardbutton = '<a class="marginrightonly" href="'.DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php">'.$langs->trans("Back").'</a>';
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="searchFormList" name="searchFormList">';
if ($sourcetype != 'salary') {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="searchFormList" name="searchFormList">';
} else {
print '<form action="'.$_SERVER["PHP_SELF"].'?status=0&type=bank-transfer&sourcetype='.$sourcetype.'" method="POST" id="searchFormList" name="searchFormList">';
}
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
@ -225,52 +257,86 @@ if ($type == 'bank-transfer') {
$label = 'NewPaymentByBankTransfer';
$typefilter = 'type='.$type;
}
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'.($typefilter ? '?'.$typefilter : ''));
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'.($typefilter ? '?'.$typefilter : '').($sourcetype ? '&sourcetype='.$sourcetype : ''));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="liste centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]);
print_liste_field_titre("Company", $_SERVER["PHP_SELF"]);
print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right ');
print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center ');
print_liste_field_titre('');
print '</tr>';
print '<tr class="liste_titre">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print '<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_facture" value="'.dol_escape_htmltag($search_facture).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print '</tr>';
print '<tr class="liste_titre">';
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre('');
}
print_liste_field_titre(($sourcetype ? "RefSalary" : "Bill"), $_SERVER["PHP_SELF"]);
print_liste_field_titre(($sourcetype ? "Employee" :"Company"), $_SERVER["PHP_SELF"]);
print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right ');
print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center ');
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre('');
}
print '</tr>';
$userstatic = new User($db);
$salarystatic = new Salary($db);
$i = 0;
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
}
$invoicestatic->fetch($obj->rowid);
if ($sourcetype != 'salary') {
$invoicestatic->fetch($obj->rowid);
} else {
$salarystatic->fetch($obj->fk_salary);
$userstatic->fetch($obj->fk_user);
}
print '<tr class="oddeven">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="right"></td>';
}
// Ref facture
print '<td>';
print $invoicestatic->getNomUrl(1, 'withdraw');
if ($sourcetype != 'salary') {
print $invoicestatic->getNomUrl(1, 'withdraw');
} else {
print $salarystatic->getNomUrl(1, 'withdraw');
}
print '</td>';
print '<td>';
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
print $thirdpartystatic->getNomUrl(1, 'customer');
if ($sourcetype != 'salary') {
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
print $thirdpartystatic->getNomUrl(1, 'customer');
} else {
print $userstatic->getNomUrl(-1, 'accountancy');
}
print '</td>';
print '<td class="right">';
@ -281,13 +347,18 @@ while ($i < min($num, $limit)) {
print '<td class="center">'.dol_print_date($db->jdate($obj->date_demande), 'day').'</td>';
print '<td class="right"></td>';
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="right"></td>';
}
print '</tr>';
$i++;
}
print "</table><br>";
print "</table>";
print "</div>";
print "<br>";
print '</form>';

View file

@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals', 'suppliers'));
@ -40,6 +41,7 @@ $langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawal
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$userid = GETPOST('userid', 'int');
$type = GETPOST('type', 'aZ09');
// Load variable for pagination
@ -73,6 +75,7 @@ if ($user->socid > 0) {
}
$type = $object->type;
$salaryBonPl = $object->checkIfSalaryBonPrelevement();
if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
} else {
@ -199,43 +202,60 @@ if ($id > 0 || $ref) {
}
// List of invoices
$sql = "SELECT pf.rowid, p.type,";
$sql .= " f.rowid as facid, f.ref as ref, f.total_ttc,";
if ($object->type == 'bank-transfer') {
$sql .= " f.ref_supplier,";
}
$sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= ", ".MAIN_DB_PREFIX."prelevement as pf";
if ($object->type != 'bank-transfer') {
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
// List of invoices or salaries
if ($salaryBonPl) {
$sql = "SELECT pf.rowid, p.type,";
$sql .= " f.rowid as salaryid, f.ref as ref, f.amount,";
$sql .= " u.rowid as userid, u.firstname, u.lastname, pl.statut as status, pl.amount as amount_requested";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON pl.fk_prelevement_bons = p.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."prelevement as pf ON pf.fk_prelevement_lignes = pl.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as f ON f.rowid = pf.fk_salary AND f.entity IN (".getEntity('salary').")";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON f.fk_user = u.rowid";
$sql .= " WHERE 1 = 1";
if ($object->id > 0) {
$sql .= " AND p.rowid = ".((int) $object->id);
}
if ($userid > 0) {
$sql .= " AND u.rowid = ".((int) $userid);
}
} else {
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql = "SELECT pf.rowid, p.type,";
$sql .= " f.rowid as facid, f.ref as ref, f.total_ttc,";
if ($object->type == 'bank-transfer') {
$sql .= " f.ref_supplier,";
}
$sql .= " s.rowid as socid, s.nom as name, pl.statut as status, pl.amount as amount_requested";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."prelevement as pf";
if ($object->type != 'bank-transfer') {
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
} else {
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.rowid";
if ($object->type != 'bank-transfer') {
$sql .= " AND pf.fk_facture = f.rowid";
} else {
$sql .= " AND pf.fk_facture_fourn = f.rowid";
}
if ($object->type != 'bank-transfer') {
$sql .= " AND f.entity IN (".getEntity('invoice').")";
} else {
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
}
if ($object->id > 0) {
$sql .= " AND p.rowid = ".((int) $object->id);
}
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
$sql .= $db->order($sortfield, $sortorder);
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.rowid";
if ($object->type != 'bank-transfer') {
$sql .= " AND pf.fk_facture = f.rowid";
} else {
$sql .= " AND pf.fk_facture_fourn = f.rowid";
}
if ($object->type != 'bank-transfer') {
$sql .= " AND f.entity IN (".getEntity('invoice').")";
} else {
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
}
if ($object->id > 0) {
$sql .= " AND p.rowid = ".((int) $object->id);
}
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
@ -248,7 +268,6 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
}
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
@ -275,18 +294,18 @@ if ($resql) {
$massactionbutton = '';
print_barre_liste($langs->trans("Invoices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
print_barre_liste(($salaryBonPl ? $langs->trans("Salaries") : $langs->trans("Invoices")), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
print"\n<!-- debut table -->\n";
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="liste centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("Bill", $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
if ($object->type == 'bank-transfer') {
print_liste_field_titre(($salaryBonPl ? "Salary" : "Bill"), $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
if ($object->type == 'bank-transfer' && !$salaryBonPl) {
print_liste_field_titre("RefSupplierShort", $_SERVER["PHP_SELF"], "f.ref_supplier", '', $param, '', $sortfield, $sortorder);
}
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("AmountInvoice", $_SERVER["PHP_SELF"], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre(($salaryBonPl ? "Employee" : "ThirdParty"), $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre(($salaryBonPl ? "AmountSalary": "AmountInvoice"), $_SERVER["PHP_SELF"], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "pl.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre('');
@ -295,58 +314,66 @@ if ($resql) {
$totalinvoices = 0;
$totalamount_requested = 0;
$invoicetmpcustomer = new Facture($db);
$invoicetmpsupplier = new FactureFournisseur($db);
if ($salaryBonPl) {
$salarytmp = new Salary($db);
$usertmp = new User($db);
} else {
$invoicetmpcustomer = new Facture($db);
$invoicetmpsupplier = new FactureFournisseur($db);
}
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
if ($obj->type == 'bank-transfer') {
$invoicetmp = $invoicetmpsupplier;
if ($salaryBonPl) {
$salarytmp->fetch($obj->salaryid);
$usertmp->fetch($obj->userid);
} else {
$invoicetmp = $invoicetmpcustomer;
}
$invoicetmp->fetch($obj->facid);
if ($obj->type == 'bank-transfer') {
$invoicetmp = $invoicetmpsupplier;
} else {
$invoicetmp = $invoicetmpcustomer;
}
$invoicetmp->fetch($obj->facid);
$thirdpartytmp->fetch($obj->socid);
$thirdpartytmp->fetch($obj->socid);
}
print '<tr class="oddeven">';
print '<td class="nowraponall">';
print $invoicetmp->getNomUrl(1);
print ($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1));
print "</td>\n";
if ($object->type == 'bank-transfer') {
if ($object->type == 'bank-transfer' && !$salaryBonPl) {
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($invoicetmp->ref_supplier).'">';
print dol_escape_htmltag($invoicetmp->ref_supplier);
print "</td>\n";
}
print '<td class="tdoverflowmax125">';
print $thirdpartytmp->getNomUrl(1);
print ($salaryBonPl ? $usertmp->getNomUrl(-1) : $thirdpartytmp->getNomUrl(1));
print "</td>\n";
// Amount of invoice
print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
print '<td class="right"><span class="amount">'.price(($salaryBonPl ? $obj->amount :$obj->total_ttc))."</span></td>\n";
// Amount requested
print '<td class="right"><span class="amount">'.price($obj->amount_requested)."</span></td>\n";
// Status of requests
print '<td class="center">';
if ($obj->statut == 0) {
print '-';
} elseif ($obj->statut == 2) {
if ($obj->status == 0) {
print $langs->trans("StatusWaiting");
} elseif ($obj->status == 2) {
if ($obj->type == 'bank-transfer') {
print $langs->trans("StatusDebited");
} else {
print $langs->trans("StatusCredited");
}
} elseif ($obj->statut == 3) {
} elseif ($obj->status == 3) {
print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
}
print "</td>";
print "<td></td>";
@ -362,7 +389,7 @@ if ($resql) {
if ($num > 0) {
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
if ($object->type == 'bank-transfer') {
if ($object->type == 'bank-transfer' && !$salaryBonPl) {
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</td>';

View file

@ -63,7 +63,7 @@ if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "p.datec";
$sortfield = ($type == 'bank-transfer' ? "datec" : "p.datec");
}
$search_line = GETPOST('search_line', 'alpha');
@ -75,6 +75,7 @@ $statut = GETPOST('statut', 'int');
$bon = new BonPrelevement($db);
$line = new LignePrelevement($db);
$company = new Societe($db);
$userstatic = new User($db);
$hookmanager->initHooks(array('withdrawalsreceiptslineslist'));
@ -115,7 +116,7 @@ if ($type == 'bank-transfer') {
}
$help_url = '';
$sql = "SELECT p.rowid, p.ref, p.statut as status, p.datec";
$sql = "SELECT p.rowid, p.ref, p.statut as status, p.datec";
$sql .= " , f.rowid as facid, f.ref as invoiceref, f.total_ttc";
$sql .= " , s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.email";
$sql .= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
@ -143,11 +144,11 @@ $sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
if ($search_line) {
$sql .= " AND pl.rowid = '".$db->escape($search_line)."'";
}
if ($search_bon) {
$sql .= natural_search("p.ref", $search_bon);
$sql .= " AND pl.rowid = '".$db->escape($search_bon)."'";
}
if ($search_line) {
$sql .= natural_search("p.ref", $search_line);
}
if ($type == 'bank-transfer') {
if ($search_code) {
@ -161,13 +162,59 @@ if ($type == 'bank-transfer') {
if ($search_company) {
$sql .= natural_search("s.nom", $search_company);
}
//get salary invoices
if ($type == 'bank-transfer') {
$sql .= " UNION";
$sql .= " SELECT p.rowid, p.ref, p.statut as status, p.datec";
$sql .= ", sl.rowid as facid, sl.ref as invoiceref, sl.amount";
$sql .= ", u.rowid as socid, CONCAT(u.firstname, ' ', u.lastname) as name, u.ref_employee as code_client, NULL as code_fournisseur, u.email";
$sql .= ", pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."prelevement as pf";
$sql .= " , ".MAIN_DB_PREFIX."salary as sl";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE pl.fk_prelevement_bons = p.rowid";
$sql .= " AND pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pf.fk_salary = sl.rowid";
$sql .= " AND sl.fk_user = u.rowid";
$sql .= " AND sl.entity IN (".getEntity('invoice').")";
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
if ($search_bon) {
$sql .= " AND pl.rowid = '".$db->escape($search_bon)."'";
}
if ($search_line) {
$sql .= natural_search("p.ref", $search_line);
}
if ($type == 'bank-transfer') {
if ($search_code) {
$sql .= natural_search("NULL", $search_code);
}
} else {
if ($search_code) {
$sql .= natural_search("s.code_client", $search_code);
}
}
if ($search_company) {
$sql .= natural_search(array("u.firstname","u.lastname"), $search_company);
}
}
// Count total nb of records
$nbtotalofrecords = '';
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
/* The fast and low memory method to get and count full list converts the sql into a sql count */
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
if ($type == 'bank-transfer') {
$sqlforcount = "SELECT COUNT(*) as nbtotalofrecords FROM (" . $sql . ") AS combined_results";
} else {
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
}
$resql = $db->query($sqlforcount);
if ($resql) {
$objforcount = $db->fetch_object($resql);
@ -332,9 +379,9 @@ print_liste_field_titre($columntitle, $_SERVER["PHP_SELF"], "p.ref", '', $param,
$totalarray['nbfield']++;
print_liste_field_titre("Line", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
print_liste_field_titre("Bill", $_SERVER["PHP_SELF"], "f.ref", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre(($type == 'bank-transfer' ? "BillsAndSalaries" : "Bills"), $_SERVER["PHP_SELF"], "f.ref", '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
print_liste_field_titre($columntitlethirdparty, $_SERVER["PHP_SELF"], $columncodethirdparty, '', $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
@ -367,7 +414,14 @@ while ($i < $imaxinloop) {
$bon->total = $obj->amount;
$object = $bon;
if ($object->checkIfSalaryBonPrelevement()) {
$userstatic->id = $obj->socid;
$userstatic->email = $obj->email;
$fullname = explode(' ', $obj->name);
$userstatic->firstname = $fullname[0];
$userstatic->lastname = isset($fullname[1]) ? $fullname[1] : '';
}
$company->id = $obj->socid;
$company->name = $obj->name;
$company->email = $obj->email;
@ -427,18 +481,29 @@ while ($i < $imaxinloop) {
$link_title = 'Invoice';
$link_picto = 'bill';
if ($type == 'bank-transfer') {
$link_to_bill = '/fourn/facture/card.php?facid=';
$link_title = 'SupplierInvoice';
$link_picto = 'supplier_invoice';
if ($bon->checkIfSalaryBonPrelevement()) {
$link_to_bill = '/salaries/card.php?id=';
$link_title = 'SalaryInvoice';
$link_picto = 'salary';
} else {
$link_to_bill = '/fourn/facture/card.php?facid=';
$link_title = 'SupplierInvoice';
$link_picto = 'supplier_invoice';
}
}
print '<a href="'.DOL_URL_ROOT.$link_to_bill.$obj->facid.'">';
print img_object($langs->trans($link_title), $link_picto);
print '&nbsp;'.$obj->invoiceref."</td>\n";
if (!$bon->checkIfSalaryBonPrelevement()) {
print '&nbsp;'.$obj->invoiceref."</td>\n";
} else {
print '&nbsp;'.(!empty($obj->invoiceref) ? $obj->invoiceref : $obj->facid)."</td>\n";
}
print '</a>';
print '</td>';
print '<td>';
print $company->getNomUrl(1);
print (!$bon->checkIfSalaryBonPrelevement() ? $company->getNomUrl(1) : $userstatic->getNomUrl(1));
print "</td>\n";

View file

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
@ -88,8 +89,8 @@ $hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
// List of invoices
$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut";
$sql .= " , s.rowid as socid, s.nom";
$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId";
$sql .= " , s.rowid as socid, s.nom as name, p.datec";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
@ -106,9 +107,28 @@ if ($type == 'bank-transfer') {
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
if ($type == 'bank-transfer') {
$sql .= " UNION";
$sql .= " SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId";
$sql .= " ,u.rowid as socid, CONCAT(u.firstname,' ', u.lastname) as name, p.datec";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND pl.fk_user = u.rowid";
$sql .= " AND p.entity = ".$conf->entity;
$sql .= " AND p.type = 'bank-transfer'";
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
}
if ($type == 'bank-transfer') {
$sortfield = 'datec';
}
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
@ -125,9 +145,11 @@ if ($result) {
print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
print "</tr>\n";
$bon = new BonPrelevement($db);
if ($num) {
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($result);
$bon->fetch($obj->bonId);
print '<tr class="oddeven">';
@ -135,8 +157,11 @@ if ($result) {
print $line->LibStatut($obj->statut, 2).'&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
print substr('000000'.$obj->rowid, -6)."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->nom."</a></td>\n";
if ($bon->checkIfSalaryBonPrelevement()) {
print '<td><a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
} else {
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->nom."</a></td>\n";
}
print '<td>'.$rej->motifs[$obj->motif].'</td>';

View file

@ -125,12 +125,12 @@ if ($resql) {
//print $st[$row[2]];
print '</td>';
print '<td align="center nowraponall">';
print '<td class="center nowraponall">';
print $row[1];
print '</td>';
print '<td class="right nowraponall">';
print round($row[1] / $nbtotal * 100, 2)." %";
print price2num($row[1] / $nbtotal * 100, 2)." %";
print '</td>';
print '<td class="right amount nowraponall">';
@ -138,7 +138,7 @@ if ($resql) {
print '</td>';
print '<td class="right nowraponall">';
print round($row[0] / $total * 100, 2)." %";
print price2num($row[0] / $total * 100, 2)." %";
print '</td>';
print '</tr>';
@ -229,17 +229,19 @@ if ($resql) {
print '<tr class="oddeven"><td>';
print $Rejet->motifs[$row[2]];
print '</td>';
print '</td><td align="center">'.$row[1];
print '<td class="center">'.$row[1];
print '</td>';
print '</td><td class="right">';
print round($row[1] / $nbtotal * 100, 2)." %";
print '<td class="right">';
print price2num($row[1] / $nbtotal * 100, 2)." %";
print '</td><td class="right">';
print price($row[0]);
print '</td><td class="right">';
print round($row[0] / $total * 100, 2)." %";
print price2num($row[0] / $total * 100, 2)." %";
print '</td></tr>';

View file

@ -74,11 +74,11 @@ $year = GETPOST('year', 'int'); // this is used for navigation previous/next. I
if (empty($year)) {
$year_current = dol_print_date(dol_now(), "%Y");
$month_current = dol_print_date(dol_now(), "%m");
$year_start = $year_current - ($nbofyear - 1);
$year_start = $year_current;
} else {
$year_current = $year;
$month_current = dol_print_date(dol_now(), "%m");
$year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
$year_start = $year;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
@ -88,14 +88,17 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$q = GETPOST("q") ? GETPOST("q", 'int') : 0;
if ($q == 0) {
// We define date_start and date_end
$year_end = $year_start + $nbofyear - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
$year_end = $year_start;
$month_start = GETPOST("month") ? GETPOST("month", 'int') : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
if (!GETPOST('month')) {
if (!$year && $month_start > $month_current) {
$year_start--;
$year_end--;
}
$month_end = $month_start - 1;
if (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1) {
$month_end = $month_start - 1;
$year_end = $year_start + 1;
}
if ($month_end < 1) {
$month_end = 12;
}

View file

@ -334,7 +334,7 @@ if (isModEnabled('project')) {
$now = dol_now();
$title = $langs->trans("SocialContribution").' - '.$langs->trans("Card");
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module_Taxes_et_charges_spéciales|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("", $title, $help_url);

View file

@ -366,7 +366,7 @@ class Cchargesociales
* @param int $fromid Id of object to clone
* @return int New id of clone
*/
public function createFromClone(User $user, $fromid)
/*public function createFromClone(User $user, $fromid)
{
dol_syslog(__METHOD__, LOG_DEBUG);
@ -406,7 +406,7 @@ class Cchargesociales
return -1;
}
}
}*/
/**
* Return a link to the user card (with optionaly the picto)
@ -419,7 +419,7 @@ class Cchargesociales
* @param string $morecss Add more css on link
* @return string String with URL
*/
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '')
/*public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '')
{
global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo;
@ -446,7 +446,7 @@ class Cchargesociales
}
$result .= $link.$this->ref.$linkend;
return $result;
}
}*/
/**
* Return the label of the status
@ -454,10 +454,10 @@ class Cchargesociales
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibStatut($mode = 0)
/*public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->status, $mode);
}
}*/
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**

View file

@ -741,9 +741,9 @@ class ChargeSociales extends CommonObject
$this->ref = 'SPECIMEN';
$this->specimen = 1;
$this->paye = 0;
$this->date = dol_now();
$this->date_ech = $this->date + 3600 * 24 * 30;
$this->periode = $this->date + 3600 * 24 * 30;
$this->date_creation = dol_now();
$this->date_ech = $this->date_creation + 3600 * 24 * 30;
$this->periode = $this->date_creation + 3600 * 24 * 30;
$this->amount = 100;
$this->label = 'Social contribution label';
$this->type = 1;

View file

@ -61,6 +61,26 @@ class PaymentSocialContribution extends CommonObject
public $tms = '';
public $datep = '';
/**
* @var string
*/
public $type_code;
/**
* @var string
*/
public $type_label;
/**
* @var int
*/
public $bank_account;
/**
* @var int
*/
public $bank_line;
/**
* @deprecated
* @see $amount

View file

@ -457,7 +457,7 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
// Filter: Ref
if (!empty($arrayfields['cs.rowid']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
@ -634,7 +634,7 @@ $i = 0;
$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
$totalarray['val'] = array();
$totalarray['val'] = array('totalttcfield'=>0);
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
@ -800,7 +800,9 @@ while ($i < $imaxinloop) {
print $bankstatic->getNomUrl(1);
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Amount
@ -808,8 +810,6 @@ while ($i < $imaxinloop) {
print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
}
$totalarray['val']['totalttcfield'] += $obj->amount;

View file

@ -113,6 +113,26 @@ class PaymentVAT extends CommonObject
*/
public $datepaye;
/**
* @var string
*/
public $type_code;
/**
* @var string
*/
public $type_label;
/**
* @var int
*/
public $bank_account;
/**
* @var int
*/
public $bank_line;
/**
* @var integer|string paiementtype
*/

View file

@ -62,6 +62,26 @@ class Tva extends CommonObject
public $type_payment;
public $num_payment;
/**
* @var DateTime
*/
public $datec;
/**
* @var int ID
*/
public $fk_type;
/**
* @var int
*/
public $paye;
/**
* @var int
*/
public $rappro;
/**
* @var integer|string totalpaid
*/

View file

@ -777,7 +777,7 @@ if (empty($reshook)) {
$objectline->date_start_real = $date_start_real_update;
$objectline->date_end = $date_end_update;
$objectline->date_end_real = $date_end_real_update;
$objectline->fk_user_cloture = $user->id;
$objectline->user_closing_id = $user->id;
//$objectline->fk_fournprice = $fk_fournprice;
$objectline->pa_ht = $pa_ht;
$objectline->rang = $objectline->rang;

View file

@ -455,7 +455,7 @@ class Contrat extends CommonObject
if ($contratline->statut != ContratLigne::STATUS_CLOSED) {
$contratline->date_end_real = $now;
$contratline->date_cloture = $now; // For backward compatibility
$contratline->fk_user_cloture = $user->id;
$contratline->user_closing_id = $user->id;
$contratline->statut = ContratLigne::STATUS_CLOSED;
$result = $contratline->close_line($user, $now, $comment, $notrigger);
if ($result < 0) {
@ -556,6 +556,12 @@ class Contrat extends CommonObject
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'contract/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@ -660,15 +666,17 @@ class Contrat extends CommonObject
}
/**
* Load a contract from database
* Load a contract from database
*
* @param int $id Id of contract to load
* @param string $ref Ref
* @param string $ref_customer Customer ref
* @param string $ref_supplier Supplier ref
* @return int <0 if KO, 0 if not found or if two records found for same ref, Id of contract if OK
* @param int $id Id of contract to load
* @param string $ref Ref
* @param string $ref_customer Customer ref
* @param string $ref_supplier Supplier ref
* @param int $noextrafields 0=Default to load extrafields, 1=No extrafields
* @param int $nolines 0=Default to load lines, 1=No lines
* @return int <0 if KO, 0 if not found or if two records found for same ref, Id of contract if OK
*/
public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '')
public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '', $noextrafields = 0, $nolines = 0)
{
$sql = "SELECT rowid, statut as status, ref, fk_soc as thirdpartyid,";
$sql .= " ref_supplier, ref_customer,";
@ -740,16 +748,23 @@ class Contrat extends CommonObject
// Retrieve all extrafields
// fetch optionals attributes and labels
$result = $this->fetch_optionals();
// Lines
if ($result >= 0 && !empty($this->table_element_line)) {
$result = $this->fetch_lines();
if (empty($noextrafields)) {
$result = $this->fetch_optionals();
if ($result < 0) {
$this->error = $this->db->lasterror();
return -4;
}
}
if ($result < 0) {
$this->error = $this->db->lasterror();
return -3;
// Lines
if (empty($nolines)) {
if ($result >= 0 && !empty($this->table_element_line)) {
$result = $this->fetch_lines();
if ($result < 0) {
$this->error = $this->db->lasterror();
return -3;
}
}
}
return $this->id;
@ -775,11 +790,12 @@ class Contrat extends CommonObject
* Load lines array into this->lines.
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
*
* @param int $only_services 0=Default, 1=Force only services (depending on setup, we may also have physical products in a contract)
* @param int $loadalsotranslation 0=Default, 1=Load also translations of product descriptions
* @return array|int Return array of contract lines
* @param int $only_services 0=Default for all, 1=Force only services (depending on setup, we may also have physical products in a contract)
* @param int $loadalsotranslation 0=Default to not load translations, 1=Load also translations of product descriptions
* @param int $noextrafields 0=Default to load extrafields, 1=Do not load the extrafields of lines
* @return array|int Return array of contract lines
*/
public function fetch_lines($only_services = 0, $loadalsotranslation = 0)
public function fetch_lines($only_services = 0, $loadalsotranslation = 0, $noextrafields = 0)
{
// phpcs:enable
$this->nbofservices = 0;
@ -895,7 +911,9 @@ class Contrat extends CommonObject
// Retrieve all extrafields for contract line
// fetch optionals attributes and labels
$line->fetch_optionals();
if (empty($noextrafields)) {
$line->fetch_optionals();
}
// multilangs
if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($objp->fk_product) && !empty($loadalsotranslation)) {
@ -2752,7 +2770,7 @@ class Contrat extends CommonObject
// Load contract
$object = new Contrat($this->db);
$object->fetch($obj->rowid); // fetch also lines
$object->fetch_thirdparty();
//$object->fetch_thirdparty();
if ($object->id <= 0) {
$error++;
@ -2768,13 +2786,16 @@ class Contrat extends CommonObject
$duration_unit = preg_replace('/\d/', '', $obj->duration);
//var_dump($expirationdate.' '.$enddatetoscan);
// Test if there is pending invoice
// Load linked ->linkedObjects (objects linked)
// @TODO Comment this line and then make the search if there is n open invoice(s) by doing a dedicated SQL COUNT request to fill $contractcanceled.
$object->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 1);
if (is_array($object->linkedObjects['facture']) && count($object->linkedObjects['facture']) > 0) {
usort($object->linkedObjects['facture'], "cmp");
// Test if there is at least 1 open invoice
if (isset($object->linkedObjects['facture']) && is_array($object->linkedObjects['facture']) && count($object->linkedObjects['facture']) > 0) {
// Sort array of linked invoices by ascending date
usort($object->linkedObjects['facture'], array('Contrat', 'contractCmpDate'));
//dol_sort_array($object->linkedObjects['facture'], 'date');
//dol_sort_array($contract->linkedObjects['facture'], 'date');
$someinvoicenotpaid=0;
foreach ($object->linkedObjects['facture'] as $idinvoice => $invoice) {
if ($invoice->statut == Facture::STATUS_DRAFT) continue; // Draft invoice are not invoice not paid
@ -2785,7 +2806,7 @@ class Contrat extends CommonObject
}
if ($someinvoicenotpaid) {
$this->output .= 'Contract '.$object->ref.' is qualified for renewal but there is '.$someinvoicenotpaid.' invoice(s) unpayed so we cancel renewal'."\n";
$contractignored[$object->id]=$object->ref;
$contractignored[$object->id] = $object->ref;
continue;
}
}
@ -2827,7 +2848,7 @@ class Contrat extends CommonObject
$actioncomm->datep = $now;
$actioncomm->datef = $now;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->socid = $object->thirdparty->id;
$actioncomm->socid = $object->socid;
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
$actioncomm->fk_element = $object->id;
@ -2867,6 +2888,21 @@ class Contrat extends CommonObject
return ($error ? 1: 0);
}
/**
* Used to sort lines by date
*
* @param Object $a 1st element to test
* @param Object $b 2nd element to test
* @return int
*/
static public function contractCmpDate($a, $b)
{
if ($a->date == $b->date) {
return strcmp((string) $a->id, (string) $b->id);
}
return ($a->date < $b->date) ? -1 : 1;
}
/**
* Return clicable link of object (with eventually picto)
*
@ -3772,7 +3808,7 @@ class ContratLigne extends CommonObjectLine
// Update object
$this->date_cloture = $date_end_real;
$this->date_end_real = $date_end_real;
$this->fk_user_cloture = $user->id;
$this->user_closing_id = $user->id;
$this->commentaire = $comment;
$error = 0;

View file

@ -382,17 +382,27 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) {
exit;
}
$db->begin();
$result = $object->delete($user);
if ($result > 0) {
$db->commit();
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
if (empty($noback)) {
if (empty($backurlforlist)) {
print 'Error backurlforlist is not defined';
exit;
}
header("Location: " . $backurlforlist);
exit;
}
} else {
$db->rollback();
$error++;
if (!empty($object->errors)) {
setEventMessages(null, $object->errors, 'errors');

View file

@ -33,6 +33,7 @@ $param = GETPOST('param', 'alphanohtml');
$css = GETPOST('css', 'alphanohtml');
$cssview = GETPOST('cssview', 'alphanohtml');
$csslist = GETPOST('csslist', 'alphanohtml');
$confirm = GETPOST('confirm', 'alpha');
if ($type == 'double' && strpos($extrasize, ',') === false) {
$extrasize = '24,8';
@ -47,6 +48,18 @@ if ($type == 'select') {
$extrasize = '';
}
$listofreservedwords = array(
'ADD', 'ALL', 'ALTER', 'ANALYZE', 'AND', 'AS', 'ASENSITIVE', 'BEFORE', 'BETWEEN', 'BINARY', 'BLOB', 'BOTH', 'CALL', 'CASCADE', 'CASE', 'CHANGE', 'CHAR', 'CHARACTER', 'CHECK', 'COLLATE', 'COLUMN', 'CONDITION', 'CONSTRAINT', 'CONTINUE', 'CONVERT', 'CREATE', 'CROSS', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER',
'CURSOR', 'DATABASE', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELAYED', 'DELETE', 'DESC', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCT', 'DISTINCTROW', 'DOUBLE', 'DROP', 'DUAL',
'EACH', 'ELSE', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXISTS', 'EXPLAIN', 'FALSE', 'FETCH', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FOREIGN', 'FULLTEXT', 'GRANT', 'GROUP', 'HAVING', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND',
'IGNORE', 'IGNORE_SERVER_IDS', 'INDEX', 'INFILE', 'INNER', 'INOUT', 'INSENSITIVE', 'INSERT', 'INT', 'INTEGER', 'INTERVAL', 'INTO', 'ITERATE',
'KEYS', 'KEYWORD', 'LEADING', 'LEAVE', 'LEFT', 'LIKE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LONGBLOB', 'LONGTEXT', 'MASTER_SSL_VERIFY_SERVER_CERT', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MODIFIES', 'NATURAL', 'NOT', 'NO_WRITE_TO_BINLOG', 'NUMERIC',
'ON', 'OPTION', 'OPTIONALLY', 'OUTER', 'OUTFILE',
'PARTITION', 'POSITION', 'PRECISION', 'PRIMARY', 'PROCEDURE', 'PURGE', 'RANGE', 'READS', 'READ_WRITE', 'REAL', 'REFERENCES', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REQUIRE', 'RESTRICT', 'RETURN', 'REVOKE', 'RIGHT', 'RLIKE',
'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SIGNAL', 'SMALLINT', 'SPATIAL', 'SPECIFIC', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN',
'TABLE', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TRAILING', 'TRIGGER', 'UNDO', 'UNIQUE', 'UNSIGNED', 'UPDATE', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', 'VARCHAR', 'VARYING',
'WHEN', 'WHERE', 'WHILE', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL'
);
// Add attribute
if ($action == 'add') {
@ -140,7 +153,7 @@ if ($action == 'add') {
// Check reserved keyword with more than 3 characters
if (!$error) {
if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'int', 'integer', 'float', 'double', 'real', 'position'))) {
if (in_array(strtoupper(GETPOST('attrname', 'aZ09')), $listofreservedwords)) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09'));
@ -314,7 +327,7 @@ if ($action == 'update') {
// Check reserved keyword with more than 3 characters
if (!$error) {
if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position')) && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) {
if (in_array(strtoupper(GETPOST('attrname', 'aZ09')), $listofreservedwords) && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09'));
@ -399,7 +412,7 @@ if ($action == 'update') {
}
// Delete attribute
if ($action == 'delete') {
if ($action == 'confirm_delete' && $confirm == "yes") {
if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST("attrname", 'aZ09'))) {
$attributekey = GETPOST('attrname', 'aZ09');

View file

@ -200,7 +200,7 @@ class box_external_rss extends ModeleBoxes
);
$this->info_box_contents[$line][2] = array(
'td' => 'class="right nowrap"',
'td' => 'class="right nowraponall"',
'text' => dol_escape_htmltag($date),
);
}

View file

@ -219,7 +219,7 @@ class box_members_by_tags extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_total right"',
'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
'asis' => 1
);
$this->info_box_contents[$line][] = array(

View file

@ -170,7 +170,7 @@ class box_members_by_type extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
@ -219,7 +219,7 @@ class box_members_by_type extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_total right"',
'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
'asis' => 1
);
$this->info_box_contents[$line][] = array(

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