diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d17347a0ad7..68fe9de68d6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -116,13 +116,13 @@ a process to follow to optimize the chance to have PRs merged efficiently... Also, some code changes need a prior approbation: -* if you want to include a new external library (into htdocs/includes directory), please ask before to the core project manager (mention @dolibarr-yoda in your issue) to see if such a library can be accepted. +* if you want to include a new external library (into htdocs/includes directory), please ask before to the core project manager (mention @dolibarr-jedi in your issue) to see if such a library can be accepted. -* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Then ask the project manager (@dolibarr-yoda) if the new data model you plan to add is compatible with curent and future works in progress and can be accepted as you suggest. +* if you add a new tables or fields, you MUST first submit a standalone PR with the data structure changes you plan to add/modify (and only data structure changes). Start development only once this data structure has been accepted. Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR (A label is added in such a case). -If the label of PR start with "Draft" or "WIP" (Work In Progress), it will not be analyzed for merging until you change the label of PR (but it can be analyzed for discussion). +If the label of PR start with "Draft" or "WIP" (Work In Progress), it will not be analyzed for merging until you change the label of the PR (but it can be analyzed for discussion). If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 186b20a051d..6b651234788 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,4 +2,4 @@ open_collective: dolibarr custom: https://wiki.dolibarr.org/index.php/Subscribe -# github: [eldy] \ No newline at end of file +github: [eldy] \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 035387834bd..13a3e6fa77b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,18 +1,18 @@ # Instructions *This is a template to help you make good pull requests. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.* *Please:* -- *only keep the "Fix", "Close" or "New" section* +- *only keep the "FIX", "CLOSE" or "NEW" section* (use uppercase to have the PR appears into the ChangeLog, lowercase will not appears) - *follow the project [contributing guidelines](/.github/CONTRIBUTING.md)* -- *replace the bracket enclosed textswith meaningful informations* +- *replace the bracket enclosed texts with meaningful information* -# Fix #[*issue_number Short description*] +# FIX|Fix #[*issue_number Short description*] [*Long description*] -# Close #[*issue_number Short description*] +# CLOSE|Close #[*issue_number Short description*] [*Long description*] -# New [*Short description*] +# NEW|New [*Short description*] [*Long description*] diff --git a/.tx/config b/.tx/config index dae10d60866..d4ca5e73180 100644 --- a/.tx/config +++ b/.tx/config @@ -170,12 +170,6 @@ source_file = htdocs/langs/en_US/hrm.lang source_lang = en_US type = MOZILLAPROPERTIES -[dolibarr.intracommreport] -file_filter = htdocs/langs//intracommreport.lang -source_file = htdocs/langs/en_US/intracommreport.lang -source_lang = en_US -type = MOZILLAPROPERTIES - [dolibarr.install] file_filter = htdocs/langs//install.lang source_file = htdocs/langs/en_US/install.lang @@ -188,6 +182,12 @@ source_file = htdocs/langs/en_US/interventions.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.intracommreport] +file_filter = htdocs/langs//intracommreport.lang +source_file = htdocs/langs/en_US/intracommreport.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.knowledgemanagement] file_filter = htdocs/langs//knowledgemanagement.lang source_file = htdocs/langs/en_US/knowledgemanagement.lang @@ -392,18 +392,18 @@ source_file = htdocs/langs/en_US/stripe.lang source_lang = en_US type = MOZILLAPROPERTIES -[dolibarr.suppliers] -file_filter = htdocs/langs//suppliers.lang -source_file = htdocs/langs/en_US/suppliers.lang -source_lang = en_US -type = MOZILLAPROPERTIES - [dolibarr.supplier_proposal] file_filter = htdocs/langs//supplier_proposal.lang source_file = htdocs/langs/en_US/supplier_proposal.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.suppliers] +file_filter = htdocs/langs//suppliers.lang +source_file = htdocs/langs/en_US/suppliers.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.ticket] file_filter = htdocs/langs//ticket.lang source_file = htdocs/langs/en_US/ticket.lang diff --git a/ChangeLog b/ChangeLog index 4625e7bc077..3f5fad835f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,188 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 15.0.0 compared to 14.0.0 ***** + +For users: +--------------- + +NEW: Online proposal signature +NEW: Can define some max limit on expense report (per period, per type or expense, ...) +NEW: Allow the use of __NEWREF__ to get for example the new reference a draft order will get after validation. +NEW: #18326 Workflow: Close order on shipment closing. +NEW: #18401 Add __NEWREF__ subtitute to get new object reference. +NEW: #18403 Add __URL_SHIPMENT__ substitute to get the URL of a shipment +NEW: #18689 REST API module: add api key generate / modify right. +NEW: #18663 Make "L'Annuaire des Entreprises" the default provider for SIREN verification for French thirdparties. +NEW: #18046 Add tags on ticket/categories +NEW: #18326 Workflow: Close order on shipment closing. +NEW: #18770 Can enter the buying price (for Weighted Average Price update) on lines during the reception step +NEW: #18814 Add legal form for Sweden +NEW: #18820 Accountancy - Add product account in import/export of thirdparty (level 3) +NEW: Accountancy - Format FEC/FEC2 - Add column NumFacture +NEW: Add $dolibarr_main_db_readonly in conf.php for readonly access. +NEW: add auto creation of agenda event on supplier_order cancellation +NEW: Add a PDF document template for Manufacturing Orders +NEW: Add budget field into task #18986 +NEW: add cancel button to `classify reception` form on supplier_orders +NEW: Added address field into contacts list +NEW: Added documents page and send mail possibility in payments +NEW: Add edit option in propal +NEW: Added linked files page and send mail possibility in payments +NEW: Add field date from/to in customer and supplier payment list +NEW: Add filter from date to date into action/evt list +NEW: Add import / export of MO and BOMLines - Close #18499 +NEW: Adding accounting export model for iSuite Expert +NEW: add link to an element by ref +NEW: add missing printFieldListFrom hook call on several lists +NEW: add MRP into Object Linked Box +NEW: Add option to hide customer code on PDF documents +NEW: Add param $nolog to avoid logging into dol_delete_recursive_dir() +NEW: Add sale representative in order and invoice list +NEW: add a setting to create PDF in PDF/A - 1b format #18990 +NEW: Add `SOCIETE_SHOW_VAT_IN_LIST` to display VAT number in combo list of thirdparties +NEW: Add sortorder on units list +NEW: Adds PDF_HIDE_PRODUCT_LABEL_IN_SUPPLIER_LINES to hide product label in supplier order lines +NEW: Add STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE to hide unit price on some pages +NEW: add support for zstd compression +NEW: Allow drag and drop on kits +NEW: Allow exporting supplier order validation date + validation user +NEW: Allows product ref generation after the form is validated with PRODUCT_GENERATE_REF_AFTER_FORM +NEW: autocomplete account group when editing an account card +NEW: Auto create invoice for payment done on an order with online payment link of order +NEW: Can edit fields of proposal when proposal is not yet signed +NEW: Can edit the translation key of an overwrote translation key. +NEW: can enable/disable external calendar by default +NEW: Can hide sender name on PDF documents +NEW: Can select lot from a combo list of existing batch numbers (in MRP consumtion) +NEW: Can set the default BOM on a product +NEW: Can set/unset the usual working day of the week (friday, saturday, sunday) +NEW: Can show progression of task into combo list of tasks +NEW: can upload the odt file for the product doc template +NEW: Contract - Add From/to input on search date +NEW: Customer Display with TakePOS +NEW: Split Sale in TakePOS +NEW: Customer invoice template list - Add input date from/to +NEW: date filter on project list and task list From->To +NEW: display shipping method and tracking url on shipment list +NEW: expense reports: conf to force amounts to be entered only including taxes +NEW: expense reports: conf to pre-fill start/end dates with bounds of current month +NEW: expense reports: show link to already existing overlapping expense report +NEW: expense reports: can make project field mandatory on lines +NEW: Expose bank account holder, label and number +NEW: feature #18986 +NEW: field and behavior in product object +NEW: generate intervention from time spent +NEW: holiday: handle monthly balance updates with cronjob +NEW: HRM integration, source code +NEW: HRM admin - Add tabs +NEW: HRM - Include more options to manage/custom dashboard +NEW: Increase size of params of actions for emailcollector +NEW: Invoice list - Use complete country select field with EEC or not +NEW: mass action delete, no more break if at least one object has child +NEW: mass action paid on customer invoice list +NEW: massaction validate on supplier orders list +NEW: Mass action send email to all attendees of an event. +NEW: expense reports: conf to pre-fill start/end dates with bounds of current month +NEW: Option "Add a link on the PDF to make the online payment" +NEW: More options to generate PDF (show Frame option, width of picture option) +NEW: Preview of pdf files of expense report lines +NEW: print without details +NEW: project time spent: conf to prevent recording time after X months +NEW: rewrite bind accountancy code finding on customer and sales invoice +NEW: Societe - Add perentity functionality on customer/supplier accountancy auxiliary account +NEW: Survey - Add a clickable link in email send +NEW: Social Contributions - Add from/to filter on list +NEW: Supplier order and proposal - Add From/to input on search date +NEW: Task - Add From/to input on search date +NEW: Add theme option THEME_ELDY_USEBORDERONTABLE +NEW: The Anti-CSRF protection MAIN_SECURITY_CSRF_WITH_TOKEN is on to value 1 by default +NEW: Update SQL : install and migration +NEW: Use an ajax call for the clicktodial feature instead of href link. +NEW: when multiple order linked to facture, show list into note. +NEW: when we delete several objects with massaction, if somes object has child we must see which objects are concerned and nevertheless delete objects which can be deleted +NEW: Editing a page in website module keep old page with name .back + + +For developers: +--------------- + +NEW: Introduce method hasRight +NEW: Can use textarea field into a confirm popup. +NEW: Can use the result_mode of mysqli driver. Save memory for list count +NEW: #18319 REST API - Shipment: Add 'close' action / endpoint / POST method. +NEW: add action trigger for member excluded +NEW: add option MAIN_IBAN_IS_NEVER_MANDATORY, MAIN_IBAN_NOT_MANDATORY, PROPAL_NOT_BILLABLE, PROPAL_REOPEN_UNSIGNED_ONLY, PROPOSAL_ARE_NOT_BILLABLE, TICKETS_MESSAGE_FORCE_MAIL +NEW: Add code codebar column on serial/lot structure +NEW: Add date_valid and date_approve columns in the list of supplier orders +NEW: add hook `beforeBodyClose` +NEW: Add hook hookGetEntity. +NEW: add hookmanager on note pages +NEW: add hook 'menuLeftMenuItems' to filter the leftmenu items +NEW: Add the property "copytoclipboard" in modulebuilder +NEW: api for knowledgemanagement +NEW: API get list of legal form of business +NEW: API list of staff units +NEW: hook after rank update +NEW: printFieldListFrom hook call on several lists +NEW: Use lang selector when using a field key 'lang' in modulebuilder +NEW: we need to be able to put more filters on deleteByParentField() function +NEW: make it easier to set the `keyword`, `keywords` and `description` attributes of an ecm file object + + + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook. +* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale. +* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param). +* The 'action=delete&file=...' has been replaced with 'action=deletefile&file=...' to avoid confusion with deletion of object lines. +* Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. + + + +***** ChangeLog for 14.0.3 compared to 14.0.2 ***** + +FIX: #18698 Supplier invoice list - "alert" checkbox not working +FIX: #18735 +FIX: #18767 : Member delete +FIX: #18854 +FIX: #18910 : MRP List SQL query syntax error with more than one extrafileds. +FIX: Accountancy - Format Quadra export - Missing line type C to create automaticly a subledger account with label +FIX: Accountancy - Missing specific filename for export on format FEC2, Ciel & repare it +FIX: Accountancy - Option of export popup are inverted +FIX: Accountancy - Some correction on export name +FIX: Accountancy - Trunc code_journal to 2 in format XIMPORT (Ciel, Sage50) +FIX: add warehouse in projects' overview count +FIX: autocalculation of the supplier price in main currency. +FIX: avoid warning if $categories is an id +FIX: Bad use of a forced contact of another company on PDF/ODT documents +FIX: Button text on proposal card to create a invoice +FIX: calculateCosts of BOM must not be included into fetch +FIX: check if greater 0 +FIX: default language defined for IN country +FIX: fetch of product with modulebuilder load too much data +FIX: Filter on categories +FIX: indentation +FIX: init hookmanager after loading $conf values +FIX: legal issue on expense report pdf (must also show price without tax) +FIX: missing filter status=1 on rss feeds +FIX: move fetch_optionnal into $ac_static->fetch() +FIX: payment using wrong type in takepos when too many payment mode +FIX: Product accountancy affectation with product_perentity activated (PR #18620) +FIX: products/services card: hidden extrafields were overridden +FIX: Propal list - Problem of pagination on date +FIX: selected lines on supplier invoice create +FIX: Selection of type "people" for membership must hide the company +FIX: select list of orders not complete when field type of company is on +FIX: support of localtax on expense report +FIX: task time: can't filter by user with pgsql + show error message +FIX: task time: keep on using natural_search +FIX: Test when date of invoie is in future (pb with TZ and offset) +FIX: translation into email for member at membership validation. +FIX: unprivileged user can see task associated with a not allowed project +FIX: user without permission can set ticket subject + ***** ChangeLog for 14.0.2 compared to 14.0.1 ***** FIX: #18353 Invoice list translation issue @@ -306,7 +488,7 @@ Following changes may create regressions for some external modules, but were nec * The ICS value for direct debit or credit transfer is now stored on each bank account instead of into the global setup. * API /setup/shipment_methods has been replaced with API /setup/shipping_methods * Field "total" renamed into "total_ht" for table llx_facture, llx_facture_rec for better field name consistency -* Field "tva" renamed into "total_tva" for table llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency +* Field "tva" renamed into "total_tva" for llx_facture, table llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency * Field "total" renamed into "total_ttc" for table llx_propal, llx_supplier_proposal for better field name consistency * If your database is PostgreSQL, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT) * If your database is MySQL or MariaDB, you need at least version 5.1 @@ -316,14 +498,45 @@ Following changes may create regressions for some external modules, but were nec * v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8. + +***** ChangeLog for 13.0.5 compared to 13.0.4 ***** + +FIX: 13.0: class CommandeFournisseurDispatch provides trigger for UPDATE but not for CREATE / DELETE +FIX: #18389 Accountancy - Bug on LDcompta10 export for supplier invoice +FIX: #18591 : Remove double quotes of SQL Queries for postgresql compatibility +FIX: Accountancy - Debug Export Sage50 / CIEL Compta / CIEL Compta Evo (Format XIMPORT) +FIX: Accountancy - Some problems of length with general & subledger account +FIX: add DISTINCT +FIX: an approved holiday can be canceled by an admin. +FIX: autocalculation of the supplier price in main currency. +FIX: better sql request +FIX: cannot add time spend when column ref is not displayed +FIX: compatibility postgre sql +FIX: holiday card: hooks uninitialized +FIX: Invoice - Missing button to reopen an abandoned situation invoice +FIX: invoice validation: when checking if any VAT rate has a negative amount, prevent false positives with -1.0E-14 amounts +FIX: list of categories in stats of supplier invoices +FIX: Manage credit note on situation invoice for calculate margin +FIX: method_exists needs object at first param +FIX: move fetch_optionnal into $ac_static->fetch() +FIX: multicompany transverse mode compatibility +FIX: on supplier order, JOIN with product fourn price table must be done with fk_soc too to avoid display several times a same line (because of same supplier product ref) +FIX: postgre filter select search extrafield +FIX: products/services card: hidden extrafields were overridden +FIX: shipping validation workflow: 'ORDER_NEW' trigger called from wrong object +FIX: task time: can't filter by user with pgsql + show error message +FIX: task time: keep on using natural_search +FIX: wrong users count in multicompany transverse mode + + ***** ChangeLog for 13.0.4 compared to 13.0.3 ***** FIX: Allow disabling of a module (not a dangerous action) even if there is problem with token (due to bugged modules). -FIX: 13.0 - fatal - missing inclusion of ajax.lib.php for calling `ajax_autocompleter()` -FIX: #17919 pictures in docs. +FIX: 13.0 - fatal - missing inclusion of ajax.lib.php for calling 'ajax_autocompleter()' +FIX: #17919 pictures in docs FIX: #18006 FIX: Accountancy - if we define a date start, automatic binding try to continue to solve old binding -FIX: Accoutancy Limit date payment not registered on purchases operations +FIX: Accountancy - Limit date payment not registered on purchases operations FIX: Can't edit replacement invoice FIX: deposit can create credit note in payment conf FIX: division by zero on create @@ -427,7 +640,7 @@ FIX: File attachment on lots/batches FIX: handling $heightforinfotot when he's superior to a page height on Supplier Invoice FIX: hourglass and hide button to pay FIX: massaction validate invoice do not regenerate PDF -FIX: missing mp4 video mime +FIX: #16627 fix missing mp4 video mime FIX: picto on shipment to reset qty to 0. Some quantities were not reset. FIX: Protection to avoid #16504 FIX: rounding amount on card updating diff --git a/README.md b/README.md index 7878f6270a7..54fdf1e958b 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,9 @@ If you don't have time to install it yourself, you can try some commercial 'read ## UPGRADING -Dolibarr supports upgrading usually wihtout the need for any (commercial) support (depending on if you use any commercial extensions) and supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate! +Dolibarr supports upgrading, usually without the need for any (commercial) support (depending on if you use any commercial extensions). It supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate! -- At first make a backup of your Dolibarr files & than [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr) +- 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](./doc/phpmatrix.md). - Overwrite all old files from '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. @@ -154,18 +154,18 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other application/modules -- Electronic Document Management (EDM) +- Electronic Document Management (EDM) - Bookmarks management - Reporting - Data export/import -- Barcodes +- Barcodes - Margin calculations - LDAP connectivity - ClickToDial integration - Mass emailing - RSS integration - Skype integration -- Social platforms linking +- Social platforms linking - Payment platforms integration (PayPal, Stripe, Paybox...) - Email-Collector @@ -179,14 +179,11 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Multi-Users and groups with finely grained rights - Multi-Currency - Multi-Company (by adding of an external module) - - Very user friendly and easy to use - customizable Dashboard - 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: - Spanish Tax RE and ISPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) @@ -197,7 +194,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Compatible with European GDPR rules - ... - Flexible PDF & ODT generation for invoices, proposals, orders... -- … +- ... ### System Environment / Requirements diff --git a/SECURITY.md b/SECURITY.md index 7d65b7e98e4..427b1cc7ae2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,11 +4,11 @@ This file contains some policies about the security reports on Dolibarr ERP CRM ## Supported Versions for security reports -| Version | Supported | -| --------- | ------------------ | -| <= 12.* | :x: | -| >= 13.* | :white_check_mark: | - +| Version | Supported | +| ---------- | ---------------------- | +| <= 14.0.1 | :x: | +| >= 14.0.2+ | :white_check_mark: except CSRF attacks| +| >= develop | :white_check_mark: | ## Reporting a Vulnerability @@ -54,12 +54,12 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us * $dolibarr_main_prod must be set to 1 into conf.php * $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be set to 1 soon by default) +* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 into backoffice menu Home - Setup - Other (this protection should be set to 3 soon by default) * The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly. -* CSRF attacks are accepted when using a POST URL, but when using GET URL, they are validated only for creating, updating or deleting data resctricted from pages restricted to admin users. +* CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3. * Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user. Scope is the web application (back office) and the APIs. @@ -90,9 +90,8 @@ Scope is the web application (back office) and the APIs. * Clickjacking/UI redressing * Physical or social engineering attempts or issues that require physical access to a victim’s computer/device * Presence of autocomplete attribute on web forms -* Vulnerabilities affecting outdated browsers or platforms +* Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself. * Logout and other instances of low-severity Cross-Site Request Forgery -* Missing cookie flags * Missing security-related HTTP headers which do not lead directly to a vulnerability * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index dca74e9e720..eb8e3ade6dc 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -57,7 +57,6 @@ RUN echo "host mail" >> /etc/msmtprc RUN echo "from local@localdomain.com" >> /etc/msmtprc RUN echo "domain localhost.localdomain" >> /etc/msmtprc RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini -RUN echo "localhost localhost.localdomain" >> /etc/hosts EXPOSE 80 diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 2167f069f25..b72118de5fb 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -46,6 +46,8 @@ services: networks: - internal-pod - external-pod + extra_hosts: + - "localhost.localdomain:127.0.0.1" mail: image: maildev/maildev diff --git a/composer.json b/composer.json index 130fda34945..8d82f530df8 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "nnnick/chartjs" : "^2.9", "stripe/stripe-php" : "6.43.1", "maximebf/debugbar" : "1.15.1", - "symfony/var-dumper" : "3" + "symfony/var-dumper" : "3.2" }, "require-dev" : { "php-parallel-lint/php-parallel-lint" : "^0", diff --git a/composer.lock b/composer.lock index 3e867f8f186..5f761cb63fe 100644 --- a/composer.lock +++ b/composer.lock @@ -591,7 +591,7 @@ }, { "name": "symfony/var-dumper", - "version": "v3.0.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", @@ -616,7 +616,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 4f80f06d444..cce6351950c 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -188,7 +188,10 @@ with: with } elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1]) >= 2)) { - +* Fix php fatal error on php 8.0 on tcpdi.php + while (list($k, $v) = each($value[1])) { +with + foreach ($value[1] as $k => $v) { JSGANTT: -------- diff --git a/dev/initdemo/initdemopassword.sh b/dev/initdemo/initdemopassword.sh index 933c3b1afa2..37264fb8e4d 100755 --- a/dev/initdemo/initdemopassword.sh +++ b/dev/initdemo/initdemopassword.sh @@ -171,7 +171,10 @@ if [ $res -ne 0 ]; then fi if [ -s "$mydir/initdemopostsql.sql" ]; then + echo A file initdemopostsql.sql was found, we execute it. mysql -P$port $base < "$mydir/initdemopostsql.sql" +else + echo No file initdemopostsql.sql found, we extra sql action done. fi diff --git a/dev/initdemo/mysqldump_dolibarr_14.0.0.sql b/dev/initdemo/mysqldump_dolibarr_14.0.0.sql index 4061fb9f4cf..e619c2c8fda 100644 --- a/dev/initdemo/mysqldump_dolibarr_14.0.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_14.0.0.sql @@ -2056,7 +2056,7 @@ CREATE TABLE `llx_c_holiday_types` ( `label` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `affect` int(11) NOT NULL, `delay` int(11) NOT NULL, - `newByMonth` double(8,5) NOT NULL DEFAULT 0.00000, + `newbymonth` double(8,5) NOT NULL DEFAULT 0.00000, `fk_country` int(11) DEFAULT NULL, `active` int(11) DEFAULT 1, PRIMARY KEY (`rowid`), diff --git a/dev/tools/fixaltlanguages.sh b/dev/tools/fixaltlanguages.sh index 955552940a9..5ed9f704df9 100755 --- a/dev/tools/fixaltlanguages.sh +++ b/dev/tools/fixaltlanguages.sh @@ -50,6 +50,10 @@ then then aaupper="SA" fi + if [ $bb = "IQ" ] + then + aaupper="SA" + fi bblower=`echo $dirshort | nawk -F"_" '{ print tolower($2) }'` @@ -57,23 +61,29 @@ then if [ "$aa" != "$bblower" -a "$dirshort" != "en_US" ] then reflang="htdocs/langs/"$aa"_"$aaupper - if [ -d $reflang -a $aa"_"$bb != $aa"_"$aaupper ] + echo $reflang" "$aa"_"$bb != $aa"_"$aaupper + + # If $reflang is a main language to use to sanitize the alternative file + if [ -d $reflang ] then - echo "***** Search original into "$reflang - echo $dirshort is an alternative language of $reflang - echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 - ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 - for fic in `ls htdocs/langs/${aa}_${bb}/*.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done - for fic in `ls htdocs/langs/${aa}_${bb}/*.lang`; - do f=`cat $fic | wc -l`; - #echo $f lines into file $fic; - if [ $f = 1 ] - then - echo Only one line remainging into file $fic, we delete it; - rm $fic - fi; - done - fi + if [ $aa"_"$bb != $aa"_"$aaupper ] + then + echo "***** Search original into "$reflang + echo $dirshort is an alternative language of $reflang + echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 + ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 + for fic in `ls htdocs/langs/${aa}_${bb}/*.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done + for fic in `ls htdocs/langs/${aa}_${bb}/*.lang`; + do f=`cat $fic | wc -l`; + #echo $f lines into file $fic; + if [ $f = 1 ] + then + echo Only one line remainging into file $fic, we delete it; + rm $fic + fi; + done + fi + fi fi done; fi diff --git a/dev/tools/spider.php b/dev/tools/spider.php new file mode 100644 index 00000000000..954978b24df --- /dev/null +++ b/dev/tools/spider.php @@ -0,0 +1,145 @@ +#!/usr/bin/env php +. + */ + +/** + * \file dev/tools/spider.php + * \brief Script to spider Dolibarr app. + * + * To use it: + * - Disable module "bookmark" + * - Exclude param optioncss, token, sortfield, sortorder + */ + +$crawledLinks=array(); +const MAX_DEPTH=2; + + +/** + * @param string $url URL + * @param string $depth Depth + * @return string String + */ +function followLink($url, $depth = 0) +{ + global $crawledLinks; + $crawling=array(); + if ($depth>MAX_DEPTH) { + echo "
The Crawler is giving up!
"; + return; + } + $options=array( + 'http'=>array( + 'method'=>"GET", + 'user-agent'=>"gfgBot/0.1\n" + ) + ); + $context=stream_context_create($options); + $doc=new DomDocument(); + @$doc->loadHTML(file_get_contents($url, false, $context)); + $links=$doc->getElementsByTagName('a'); + $pageTitle=getDocTitle($doc, $url); + $metaData=getDocMetaData($doc); + foreach ($links as $i) { + $link=$i->getAttribute('href'); + if (ignoreLink($link)) continue; + $link=convertLink($url, $link); + if (!in_array($link, $crawledLinks)) { + $crawledLinks[]=$link; + $crawling[]=$link; + insertIntoDatabase($link, $pageTitle, $metaData, $depth); + } + } + foreach ($crawling as $crawlURL) + followLink($crawlURL, $depth+1); +} + +/** + * @param string $site Site + * @param string $path Path + * @return string String + */ +function convertLink($site, $path) +{ + if (substr_compare($path, "//", 0, 2)==0) + return parse_url($site)['scheme'].$path; + elseif (substr_compare($path, "http://", 0, 7)==0 or + substr_compare($path, "https://", 0, 8)==0 or + substr_compare($path, "www.", 0, 4)==0) + return $path; + else return $site.'/'.$path; +} + +/** + * @param string $url URL + * @return boolean + */ +function ignoreLink($url) +{ + return $url[0]=="#" or substr($url, 0, 11) == "javascript:"; +} + +/** + * @param string $link URL + * @param string $title Title + * @param string $metaData Array + * @param int $depth Depth + * @return void + */ +function insertIntoDatabase($link, $title, &$metaData, $depth) +{ + //global $crawledLinks; + + echo "Inserting new record {URL= ".$link.", Title = '$title', Description = '".$metaData['description']."', Keywords = ' ".$metaData['keywords']."'}


"; + + //²$crawledLinks[]=$link; +} + +/** + * @param string $doc Doc + * @param string $url URL + * @return string URL/Title + */ +function getDocTitle(&$doc, $url) +{ + $titleNodes=$doc->getElementsByTagName('title'); + if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue)) + return $url; + $title=str_replace('', '\n', $titleNodes[0]->nodeValue); + return (strlen($title)<1)?$url:$title; +} + +/** + * @param string $doc Doc + * @return array Array + */ +function getDocMetaData(&$doc) +{ + $metaData=array(); + $metaNodes=$doc->getElementsByTagName('meta'); + foreach ($metaNodes as $node) + $metaData[$node->getAttribute("name")] = $node->getAttribute("content"); + if (!isset($metaData['description'])) + $metaData['description']='No Description Available'; + if (!isset($metaData['keywords'])) $metaData['keywords']=''; + return array( + 'keywords'=>str_replace('', '\n', $metaData['keywords']), + 'description'=>str_replace('', '\n', $metaData['description']) + ); +} + + +followLink("http://localhost/dolibarr_dev/htdocs"); diff --git a/dev/translation/strip_language_file.php b/dev/translation/strip_language_file.php index f3287db6128..3467b648457 100755 --- a/dev/translation/strip_language_file.php +++ b/dev/translation/strip_language_file.php @@ -177,7 +177,7 @@ foreach ($filesToProcess as $fileToProcess) { // Start reading and parsing English - + $aEnglish = array(); if ($handle = fopen($lEnglishFile, 'r')) { print "Read English File $lEnglishFile:\n"; $cnt = 0; @@ -246,6 +246,9 @@ foreach ($filesToProcess as $fileToProcess) { fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/', '', $fileToProcess))."\n"); + $fileFirstFound = array(); + $lineFirstFound = array(); + $cnt = 0; while (($line = fgets($handle)) !== false) { $cnt++; @@ -299,6 +302,7 @@ foreach ($filesToProcess as $fileToProcess) { } // String exists in both files and value into alternative language differs from main language but also from english files + // so we keep it. if ((! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key] && ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key]) || in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 6f510ad3706..c2ac133069d 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -38,6 +38,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $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 $search_account = GETPOST('search_account', 'alpha'); @@ -51,14 +52,14 @@ $confirm = GETPOST('confirm', 'alpha'); $chartofaccounts = GETPOST('chartofaccounts', 'int'); -$permissiontoadd = $user->rights->accounting->chartofaccount; -$permissiontodelete = $user->rights->accounting->chartofaccount; +$permissiontoadd = !empty($user->rights->accounting->chartofaccount); +$permissiontodelete = !empty($user->rights->accounting->chartofaccount); // Security check if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->chartofaccount) { +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -195,7 +196,7 @@ if (empty($reshook)) { } elseif ($action == 'enable' && $permissiontoadd) { if ($accounting->fetch($id)) { $mode = GETPOST('mode', 'int'); - $result = $accounting->account_activate($id, $mode); + $result = $accounting->accountActivate($id, $mode); } $action = 'update'; if ($result < 0) { @@ -392,7 +393,7 @@ if ($resql) { } print ""; print ajax_combobox("chartofaccounts"); - print ''; + print ''; print '
'; print '
'; @@ -438,43 +439,37 @@ if ($resql) { print $searchpicto; print ''; print ''; - $totalarray = array(); print ''; if (!empty($arrayfields['aa.account_number']['checked'])) { print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; } if (!empty($arrayfields['aa.label']['checked'])) { print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; } if (!empty($arrayfields['aa.labelshort']['checked'])) { print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; } if (!empty($arrayfields['aa.account_parent']['checked'])) { print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); - $totalarray['nbfield']++; } if (!empty($arrayfields['aa.pcg_type']['checked'])) { print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); - $totalarray['nbfield']++; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; } } if (!empty($arrayfields['aa.active']['checked'])) { print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $accountstatic = new AccountingAccount($db); $accountparent = new AccountingAccount($db); + $totalarray = array(); + $totalarray['nbfield'] = 0; $i = 0; while ($i < min($num, $limit)) { diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 0f4d538cfac..97a460beaac 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -78,7 +78,7 @@ $search_country_id = GETPOST('search_country_id', 'int'); if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->chartofaccount) { +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -535,7 +535,7 @@ if ($id) { } print ''; - print ''; + print ''; print ''; print ""; @@ -553,16 +553,16 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $param = '&id='.$id; + $param = '&id='.urlencode($id); if ($search_country_id > 0) { - $param .= '&search_country_id='.$search_country_id; + $param .= '&search_country_id='.urlencode($search_country_id); } $paramwithsearch = $param; if ($sortorder) { - $paramwithsearch .= '&sortorder='.$sortorder; + $paramwithsearch .= '&sortorder='.urlencode($sortorder); } if ($sortfield) { - $paramwithsearch .= '&sortfield='.$sortfield; + $paramwithsearch .= '&sortfield='.urlencode($sortfield); } // There is several pages @@ -631,7 +631,7 @@ if ($id) { fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit'); } - print ' '; + print ' '; print ' '; } else { $tmpaction = 'view'; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index b629e45cf0d..9430bf33439 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -48,7 +48,7 @@ $label = GETPOST('label', 'alpha'); if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->chartofaccount) { +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -61,7 +61,7 @@ $object = new AccountingAccount($db); */ if (GETPOST('cancel', 'alpha')) { - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + $urltogo = $backtopage ? $backtopage : DOL_URL_ROOT.'/accountancy/admin/account.php'; header("Location: ".$urltogo); exit; } @@ -75,7 +75,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; } else { - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS); + $sql = "SELECT pcg_version FROM " . MAIN_DB_PREFIX . "accounting_system WHERE rowid = ".((int) $conf->global->CHARTOFACCOUNTS); dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result = $db->query($sql); @@ -121,7 +121,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) { } if (!$error) { setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + $urltogo = $backtopage ? $backtopage : DOL_URL_ROOT.'/accountancy/admin/account.php'; header("Location: " . $urltogo); exit; } @@ -138,7 +138,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) { } else { $result = $object->fetch($id); - $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS); + $sql = "SELECT pcg_version FROM ".MAIN_DB_PREFIX."accounting_system WHERE rowid=".((int) $conf->global->CHARTOFACCOUNTS); dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); @@ -257,7 +257,20 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); print ''; print ''; - print ''; + print ''; + // autosuggest from existing account types if found + print ''; + $sql = "SELECT DISTINCT pcg_type FROM " . MAIN_DB_PREFIX . "accounting_account"; + $sql .= " WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) . "'"; + $sql .= ' AND entity in ('.getEntity('accounting_account', 0).')'; // Always limit to current entity. No sharing in accountancy. + $sql .= ' LIMIT 50000'; // just as a sanity check + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + print ''; print ''; // Category @@ -320,7 +333,20 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); print ''; print ''; - print ''; + print ''; + // autosuggest from existing account types if found + print ''; + $sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account'; + $sql .= " WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) . "'"; + $sql .= ' AND entity in ('.getEntity('accounting_account', 0).')'; // Always limit to current entity. No sharing in accountancy. + $sql .= ' LIMIT 50000'; // just as a sanity check + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + print ''; print ''; // Category @@ -335,11 +361,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print $form->buttonsSaveCancel(); print ''; } else { diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index bee481bebd6..39aa21f2d63 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -110,7 +110,7 @@ print ''; print ''; print ''; // Select the accounts @@ -137,7 +137,7 @@ if (!empty($cat_id)) { print '
'; print ajax_combobox('cpt_bk'); */ - print ' '; + print ' '; } print ''; } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9a8a84893fe..d914b825b7f 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2011-2021 Alexandre Spangaro * * 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 @@ -91,19 +91,19 @@ $tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account $tabsqlsort = array(); $tabsqlsort[32] = "position ASC"; -// Nom des champs en resultat de select pour affichage du dictionnaire +// Name of the fields in the result of select to display the dictionary $tabfield = array(); $tabfield[32] = "code,label,range_account,category_type,formula,position,country"; -// Nom des champs d'edition pour modification d'un enregistrement +// Name of editing fields for record modification $tabfieldvalue = array(); $tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id"; -// Nom des champs dans la table pour insertion d'un enregistrement +// Name of the fields in the table for inserting a record $tabfieldinsert = array(); $tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country"; -// Nom du rowid si le champ n'est pas de type autoincrement +// Name of the rowid if the field is not of type autoincrement // Example: "" if id field is "rowid" and has autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on $tabrowid = array(); @@ -151,7 +151,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($value == 'range_account' && empty($_POST['range_account'])) { continue; } - if ($value == 'country' || $value == 'country_id') { + if (($value == 'country' || $value == 'country_id') && (!empty($_POST['country_id']))) { continue; } if (!GETPOSTISSET($value) || GETPOST($value) == '') { @@ -176,6 +176,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($fieldnamekey == 'category_type') { $fieldnamekey = 'Calculated'; } + if ($fieldnamekey == 'country') { + $fieldnamekey = 'Country'; + } setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } @@ -263,7 +266,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { } } - // Si verif ok et action modify, on modifie la ligne + // If check ok and action modify, we modify the line if ($ok && GETPOST('actionmodify', 'alpha')) { if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; @@ -430,12 +433,12 @@ print load_fiche_titre($titre, $linkback, $titlepicto); print ''.$langs->trans("AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv("ByPersonalizedAccountGroups")).'

'; -// Confirmation de la suppression de la ligne +// Confirmation of the deletion of the line if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } -// Complete requete recherche valeurs avec critere de tri +// Complete search query with sorting criteria $sql = $tabsql[$id]; if ($search_country_id > 0) { @@ -558,7 +561,7 @@ if ($tabname[$id]) { } print '
'; print ""; @@ -580,7 +583,7 @@ if ($resql) { $param = '&id='.$id; if ($search_country_id > 0) { - $param .= '&search_country_id='.$search_country_id; + $param .= '&search_country_id='.urlencode($search_country_id); } $paramwithsearch = $param; if ($sortorder) { @@ -634,14 +637,14 @@ if ($resql) { // Title of lines print ''; foreach ($fieldlist as $field => $value) { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees - $showfield = 1; // By defaut + // Determines the name of the field in relation to the possible names + // in data dictionaries + $showfield = 1; // By default $class = "left"; $sortable = 1; $valuetoshow = ''; - $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = ucfirst($fieldlist[$field]); // By default $valuetoshow = $langs->trans($valuetoshow); // try to translate if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); @@ -734,14 +737,14 @@ if ($resql) { print ''; print ''; } else { $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; @@ -811,7 +814,7 @@ if ($resql) { // Modify link if ($canbemodified) { - print ''; + print ''; } else { print ''; } @@ -820,7 +823,7 @@ if ($resql) { if ($iserasable) { print ''; diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index a7873b72b90..437ff1b7116 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -109,7 +109,7 @@ foreach ($list_account_main as $key) { print ''; // Value print ''; print ''; } @@ -124,7 +124,7 @@ print ''; print "
'.$langs->trans("AccountingCategory").''; $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1); -print ''; +print ''; print '
'; - print ''; + print ''; print '
'; print ''; print ''; - print ''; + print ''; print '
'; print ''; print '
'.img_edit().''.img_edit().' '; if ($user->admin) { - print ''.img_delete().''; + print ''.img_delete().''; } //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1); print '
\n"; -print '
'; +print '
'; print ''; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 79a5c0975b7..5d78036159a 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -186,7 +186,7 @@ foreach ($list_account as $key) { print ''.$label.''; // Value print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts'); + print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts'); print ''; print ''; } @@ -196,7 +196,7 @@ foreach ($list_account as $key) { print "\n"; -print '
'; +print '
'; print ''; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 4338d7ad803..44c5309f531 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -52,7 +52,7 @@ $langs->loadLangs(array("admin", "compta")); if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->fiscalyear->write) { // If we can read accounting records, we should be able to see fiscal year. +if (empty($user->rights->accounting->fiscalyear->write)) { // If we can read accounting records, we should be able to see fiscal year. accessforbidden(); } diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 16463ec027b..2aa33f21645 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -242,11 +242,7 @@ if ($action == 'create') { print ''; - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print $form->buttonsSaveCancel(); print ''; diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index d472350fab7..77ec988143a 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -33,7 +33,7 @@ $langs->loadLangs(array("admin", "compta")); if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->fiscalyear->write) { +if (empty($user->rights->accounting->fiscalyear->write)) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index f8c0c95d3c1..309dc094e82 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2019 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -260,6 +260,22 @@ $linkback = ''; //$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($title, $linkback, 'accountancy'); +// Show message if accountancy hidden options are activated to help to resolve some problems +if (!$user->admin) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + print '
' . $langs->trans("ConstantIsOn", "FACTURE_DEPOSITS_ARE_JUST_PAYMENTS") . '
'; + } + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + print '
' . $langs->trans("ConstantIsOn", "ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY") . '
'; + } + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + print '
' . $langs->trans("ConstantIsOn", "MAIN_COMPANY_PERENTITY_SHARED") . '
'; + } + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + print '
' . $langs->trans("ConstantIsOn", "MAIN_PRODUCT_PERENTITY_SHARED") . '
'; + } +} + print '
'; print ''; print ''; @@ -446,7 +462,7 @@ print ''; print ''; -print '
'; +print '
'; print '
'; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 9ba9d8a6e20..e60deef59a3 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -494,7 +494,7 @@ if ($id) { } print ''; - print ''; + print ''; print ''; print ""; @@ -512,7 +512,7 @@ if ($id) { $param = '&id='.$id; if ($search_country_id > 0) { - $param .= '&search_country_id='.$search_country_id; + $param .= '&search_country_id='.urlencode($search_country_id); } $paramwithsearch = $param; if ($sortorder) { @@ -606,13 +606,13 @@ if ($id) { print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'; print ''; } else { $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index e29653a3e40..d98357bc93c 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -41,7 +41,7 @@ $langs->loadLangs(array("companies", "compta", "accountancy", "products")); if (empty($conf->accounting->enabled)) { accessforbidden(); } -if (!$user->rights->accounting->bind->write) { +if (empty($user->rights->accounting->bind->write)) { accessforbidden(); } @@ -70,6 +70,7 @@ $search_onpurchase = GETPOST('search_onpurchase', 'alpha'); $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); if (empty($accounting_product_mode)) { $accounting_product_mode = 'ACCOUNTANCY_SELL'; @@ -186,19 +187,38 @@ if ($action == 'update') { $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; $ko++; } else { - $db->begin(); - + $sql = ''; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_perentity (fk_product, entity, '".$db->escape($accountancy_field_name)."')"; - $sql .= " VALUES (".((int) $productid).", ".((int) $conf->entity).", '".$db->escape($accounting->account_number)."')"; - $sql .= " ON DUPLICATE KEY UPDATE ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; + $sql_exists = "SELECT rowid FROM " . MAIN_DB_PREFIX . "product_perentity"; + $sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity); + $resql_exists = $db->query($sql_exists); + if (!$resql_exists) { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$resql_exists.'
'; + $ko++; + } else { + $nb_exists = $db->num_rows($resql_exists); + if ($nb_exists <= 0) { + // insert + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (fk_product, entity, '" . $db->escape($accountancy_field_name) . "')"; + $sql .= " VALUES (" . ((int) $productid) . ", " . ((int) $conf->entity) . ", '" . $db->escape($accounting->account_number) . "')"; + } else { + $obj_exists = $db->fetch_object($resql_exists); + // update + $sql = "UPDATE " . MAIN_DB_PREFIX . "product_perentity"; + $sql .= " SET " . $accountancy_field_name . " = '" . $db->escape($accounting->account_number) . "'"; + $sql .= " WHERE rowid = " . ((int) $obj_exists->rowid); + } + } } else { $sql = " UPDATE ".MAIN_DB_PREFIX."product"; $sql .= " SET ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; $sql .= " WHERE rowid = ".((int) $productid); } - dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); + dol_syslog("/accountancy/admin/productaccount.php", LOG_DEBUG); + + $db->begin(); + if ($db->query($sql)) { $ok++; $db->commit(); @@ -234,35 +254,35 @@ $form = new FormAccounting($db); // so we need to get those the rowid of those default value first $accounting = new AccountingAccount($db); // TODO: we should need to check if result is already exists accountaccount rowid..... -$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); -$aarowid_servbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT, 1); -$aarowid_servbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT, 1); -$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); -$aarowid_prodbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT, 1); -$aarowid_prodbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT, 1); -$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); -$aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1); -$aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1); -$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1); -$aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1); -$aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); +$aarowid_servbuy = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT'), 1); +$aarowid_servbuy_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'), 1); +$aarowid_servbuy_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'), 1); +$aarowid_prodbuy = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT'), 1); +$aarowid_prodbuy_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT'), 1); +$aarowid_prodbuy_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT'), 1); +$aarowid_servsell = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT'), 1); +$aarowid_servsell_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT'), 1); +$aarowid_servsell_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT'), 1); +$aarowid_prodsell = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT'), 1); +$aarowid_prodsell_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT'), 1); +$aarowid_prodsell_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT'), 1); -$aacompta_servbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_intra = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_export = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_export = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_intra = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_export = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_export = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servbuy_intra = getDolGlobalString('ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servbuy_export = getDolGlobalString('ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodbuy_intra = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodbuy_export = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servsell_intra = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servsell_export = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodsell_intra = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); llxHeader('', $langs->trans("ProductsBinding")); -$pcgverid = $conf->global->CHARTOFACCOUNTS; +$pcgverid = getDolGlobalString('CHARTOFACCOUNTS'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); if (empty($pcgvercode)) { $pcgvercode = $pcgverid; @@ -329,7 +349,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); -dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG); +dol_syslog("/accountancy/admin/productaccount.php", LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index ad1804048c3..cc0d4de9f31 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -36,6 +36,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $massaction = GETPOST('massaction', 'aZ09'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingsubaccountlist'; // To manage different context of search $search_subaccount = GETPOST('search_subaccount', 'alpha'); @@ -46,7 +47,7 @@ $search_type = GETPOST('search_type', 'int'); if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->chartofaccount) { +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -367,6 +368,7 @@ if ($resql) { print "\n"; $totalarray = array(); + $totalarray['nbfield'] = 0; $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -439,13 +441,13 @@ if ($resql) { $e = ''; // Customer if ($obj->type == 1) { - $e .= ''.img_edit().''; + $e .= ''.img_edit().''; } elseif ($obj->type == 2) { // Supplier - $e .= ''.img_edit().''; + $e .= ''.img_edit().''; } elseif ($obj->type == 3) { // User - $e .= ''.img_edit().''; + $e .= ''.img_edit().''; } print $e; print ''."\n"; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index b84fe255760..80dddd28edb 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ09'); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -120,19 +121,19 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $filter = array(); if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int'); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int'); + $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int'); } if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.$search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.$search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; @@ -429,7 +430,7 @@ if ($action != 'export_csv') { print ''; print ''.$accounting_account.''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { - print ''.price($opening_balance).''; + print ''.price(price2num($opening_balance, 'MT')).''; } $urlzoom = ''; @@ -443,9 +444,9 @@ if ($action != 'export_csv') { } } // Debit - print ''.price($line->debit).''; + print ''.price(price2num($line->debit, 'MT')).''; // Credit - print ''.price($line->credit).''; + print ''.price(price2num($line->credit, 'MT')).''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print ''.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).''; @@ -466,10 +467,10 @@ if ($action != 'export_csv') { if (!empty($show_subgroup)) { print ''.$langs->trans("SubTotal").':'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { - print ''.price($sous_total_opening_balance).''; + print ''.price(price2num($sous_total_opening_balance, 'MT')).''; } - print ''.price($sous_total_debit).''; - print ''.price($sous_total_credit).''; + print ''.price(price2num($sous_total_debit, 'MT')).''; + print ''.price(price2num($sous_total_credit, 'MT')).''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print '' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . ''; } else { @@ -481,10 +482,10 @@ if ($action != 'export_csv') { print ''.$langs->trans("AccountBalance").':'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { - print ''.price($total_opening_balance).''; + print ''.price(price2num($total_opening_balance, 'MT')).''; } - print ''.price($total_debit).''; - print ''.price($total_credit).''; + print ''.price(price2num($total_debit, 'MT')).''; + print ''.price(price2num($total_credit, 'MT')).''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print '' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . ''; } else { diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c156a388735..b772da3ce08 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -389,11 +389,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print $form->buttonsSaveCancel("Create"); print ''; } else { @@ -437,7 +433,7 @@ if ($action == 'create') { print $langs->trans('Docdate'); print ''; if ($action != 'editdate') { - print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).''; + print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).''; } print ''; print ''; @@ -450,7 +446,7 @@ if ($action == 'create') { print ''; print ''; print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); - print ''; + print ''; print ''; } else { print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; @@ -464,7 +460,7 @@ if ($action == 'create') { print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') { - print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; } print ''; print ''; @@ -477,7 +473,7 @@ if ($action == 'create') { print ''; print ''; print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); - print ''; + print ''; print ''; } else { print $object->code_journal; @@ -491,7 +487,7 @@ if ($action == 'create') { print $langs->trans('Piece'); print ''; if ($action != 'editdocref') { - print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; } print ''; print ''; @@ -504,7 +500,7 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; + print ''; print ''; } else { print $object->doc_ref; @@ -516,10 +512,10 @@ if ($action == 'create') { print ''; - print '
'; + print '
'; print '
'; - print ''; + print '
'; // Doc type if (!empty($object->doc_type)) { @@ -595,7 +591,7 @@ if ($action == 'create') { */ print "
\n"; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index bc260c77ed3..1b2f376c33f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -530,25 +530,25 @@ $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key.'=\''.$db->idate($value).'\''; + $sqlwhere[] = $key."='".$db->idate($value)."'"; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key.'\''.$db->idate($value).'\''; + $sqlwhere[] = $key."'".$db->idate($value)."'"; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=') { - $sqlwhere[] = $key.'\''.$db->escape($value).'\''; + $sqlwhere[] = $key."'".$db->escape($value)."'"; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key.'='.$value; + $sqlwhere[] = $key.'='.((int) $value); } elseif ($key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\''; + $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'"; } elseif ($key == 't.subledger_account') { $sqlwhere[] = natural_search($key, $value, 0, 1); } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key.'\''.$db->idate($value).'\''; + $sqlwhere[] = $key."'".$db->idate($value)."'"; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key.'\''.$db->idate($value).'\''; + $sqlwhere[] = $key."'".$db->idate($value)."'"; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key.'\''.$db->idate($value).'\''; + $sqlwhere[] = $key."'".$db->idate($value)."'"; } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { - $sqlwhere[] = $key.'\''.$db->idate($value).'\''; + $sqlwhere[] = $key."'".$db->idate($value)."'"; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -591,7 +591,7 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex if (!empty($accountancyexport->errors)) { setEventMessages('', $accountancyexport->errors, 'errors'); - } elseif (!$notifiedexportdate || !$notifiedvalidationdate) { + } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { // Specify as export : update field date_export or date_validated $error = 0; $db->begin(); @@ -602,17 +602,18 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET"; - if (!$notifiedexportdate && !$notifiedvalidationdate) { + if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { $sql .= " date_export = '".$db->idate($now)."'"; $sql .= ", date_validated = '".$db->idate($now)."'"; - } elseif (!$notifiedexportdate) { + } elseif (!empty($notifiedexportdate)) { $sql .= " date_export = '".$db->idate($now)."'"; - } elseif (!$notifiedvalidationdate) { + } elseif (!empty($notifiedvalidationdate)) { $sql .= " date_validated = '".$db->idate($now)."'"; } $sql .= " WHERE rowid = ".((int) $movement->id); - dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); + dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); + $result = $db->query($sql); if (!$result) { $error++; @@ -1250,7 +1251,7 @@ while ($i < min($num, $limit)) { } if (empty($line->date_validation)) { if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + print ''.img_delete().''; } } print ''; @@ -1274,7 +1275,7 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { print ''; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 27f23d36a74..22ba2d3f0b1 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -904,7 +904,7 @@ while ($i < min($num, $limit)) { } if (empty($line->date_validation)) { if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + print ''.img_delete().''; } } print ''; @@ -957,7 +957,7 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { print ''; } diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 5e83c729fb1..101a8897bb5 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -915,7 +915,7 @@ while ($i < min($num, $limit)) { } if (empty($line->date_validation)) { if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + print ''.img_delete().''; } } print ''; @@ -968,7 +968,7 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { print ''; } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 77d10516daa..7657e997ff6 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -212,7 +212,7 @@ class AccountancyCategory // extends CommonObject $sql .= " ".(!isset($this->position) ? 'NULL' : ((int) $this->position)).","; $sql .= " ".(!isset($this->fk_country) ? 'NULL' : ((int) $this->fk_country)).","; $sql .= " ".(!isset($this->active) ? 'NULL' : ((int) $this->active)); - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; $this->db->begin(); @@ -433,7 +433,7 @@ class AccountancyCategory // extends CommonObject $this->lines_display = array(); - dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -632,7 +632,7 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE aa.rowid = ".((int) $cpt_id); $this->db->begin(); - dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ec24af642fd..2c4dbfd51cd 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -59,6 +59,8 @@ class AccountancyExport public static $EXPORT_TYPE_LDCOMPTA10 = 120; public static $EXPORT_TYPE_GESTIMUMV3 = 130; public static $EXPORT_TYPE_GESTIMUMV5 = 135; + public static $EXPORT_TYPE_ISUITEEXPERT = 200; + // Generic FEC after that public static $EXPORT_TYPE_FEC = 1000; public static $EXPORT_TYPE_FEC2 = 1010; @@ -123,6 +125,7 @@ class AccountancyExport self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans('Modelcsv_Gestinumv5'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), self::$EXPORT_TYPE_FEC2 => $langs->trans('Modelcsv_FEC2'), + self::$EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert', ); ksort($listofexporttypes, SORT_NUMERIC); @@ -158,6 +161,7 @@ class AccountancyExport self::$EXPORT_TYPE_GESTIMUMV5 => 'gestimumv5', self::$EXPORT_TYPE_FEC => 'fec', self::$EXPORT_TYPE_FEC2 => 'fec2', + self::$EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert', ); return $formatcode[$type]; @@ -243,6 +247,10 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_FEC2'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), + self::$EXPORT_TYPE_ISUITEEXPERT => array( + 'label' => 'iSuite Expert', + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), ), 'cr'=> array( '1' => $langs->trans("Unix"), @@ -334,6 +342,9 @@ class AccountancyExport case self::$EXPORT_TYPE_FEC2: $this->exportFEC2($TData); break; + case self::$EXPORT_TYPE_ISUITEEXPERT : + $this->exportiSuiteExpert($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -903,7 +914,8 @@ class AccountancyExport print "ValidDate".$separator; print "Montantdevise".$separator; print "Idevise".$separator; - print "DateLimitReglmt"; + print "DateLimitReglmt".$separator; + print "NumFacture".$separator; print $end_line; foreach ($objectLines as $line) { @@ -913,9 +925,25 @@ class AccountancyExport $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); - $date_validation = dol_print_date($line->date_validated, '%Y%m%d'); + $date_validation = dol_print_date($line->date_validation, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + if ($line->doc_type == 'customer_invoice') { + // Customer invoice + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $invoice->fetch($line->fk_doc); + + $refInvoice = $invoice->ref; + } elseif ($line->doc_type == 'supplier_invoice') { + // Supplier invoice + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $invoice = new FactureFournisseur($db); + $invoice->fetch($line->fk_doc); + + $refInvoice = $invoice->ref_supplier; + } + // FEC:JournalCode print $line->code_journal . $separator; @@ -973,6 +1001,9 @@ class AccountancyExport // FEC_suppl:DateLimitReglmt print $date_limit_payment; + // FEC_suppl:NumFacture + print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1) . $separator; + print $end_line; } } @@ -1009,7 +1040,8 @@ class AccountancyExport print "ValidDate".$separator; print "Montantdevise".$separator; print "Idevise".$separator; - print "DateLimitReglmt"; + print "DateLimitReglmt".$separator; + print "NumFacture".$separator; print $end_line; foreach ($objectLines as $line) { @@ -1019,9 +1051,25 @@ class AccountancyExport $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); - $date_validation = dol_print_date($line->date_validated, '%Y%m%d'); + $date_validation = dol_print_date($line->date_validation, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + if ($line->doc_type == 'customer_invoice') { + // Customer invoice + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $invoice->fetch($line->fk_doc); + + $refInvoice = $invoice->ref; + } elseif ($line->doc_type == 'supplier_invoice') { + // Supplier invoice + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $invoice = new FactureFournisseur($db); + $invoice->fetch($line->fk_doc); + + $refInvoice = $invoice->ref_supplier; + } + // FEC:JournalCode print $line->code_journal . $separator; @@ -1079,6 +1127,10 @@ class AccountancyExport // FEC_suppl:DateLimitReglmt print $date_limit_payment; + // FEC_suppl:NumFacture + print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1) . $separator; + + print $end_line; } } @@ -1806,6 +1858,62 @@ class AccountancyExport } } + /** + * Export format : iSuite Expert + * + * by OpenSolus [https://opensolus.fr] + * + * @param array $objectLines data + * + * @return void + */ + public function exportiSuiteExpert($objectLines) + { + $this->separator = ';'; + $this->end_line = "\r\n"; + + + foreach ($objectLines as $line) { + $tab = array(); + + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + + $tab[] = $line->piece_num; + $tab[] = $date; + $tab[] = substr($date, 6, 4); + $tab[] = substr($date, 3, 2); + $tab[] = substr($date, 0, 2); + $tab[] = $line->doc_ref; + //Conversion de chaine UTF8 en Latin9 + $tab[] = mb_convert_encoding(str_replace(' - Compte auxiliaire', '', $line->label_operation), "Windows-1252", 'UTF-8'); + + //Calcul de la longueur des numéros de comptes + $taille_numero = strlen(length_accountg($line->numero_compte)); + + //Création du numéro de client générique + $numero_cpt_client = '411'; + for ($i = 1; $i <= ($taille_numero - 3); $i++) { + $numero_cpt_client .= '0'; + } + + //Création des comptes auxiliaire des clients + if (length_accountg($line->numero_compte) == $numero_cpt_client) { + $tab[] = rtrim(length_accounta($line->subledger_account), "0"); + } else { + $tab[] = length_accountg($line->numero_compte); + } + $nom_client = explode(" - ", $line->label_operation); + $tab[] = mb_convert_encoding($nom_client[0], "Windows-1252", 'UTF-8'); + $tab[] = price($line->debit); + $tab[] = price($line->credit); + $tab[] = price($line->montant); + $tab[] = $line->code_journal; + + $separator = $this->separator; + print implode($separator, $tab) . $this->end_line; + } + } + /** * trunc * diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 1b481027ac0..a62dddd6a26 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -105,7 +105,7 @@ class AccountancySystem $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; } - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -143,9 +143,9 @@ class AccountancySystem $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; $sql .= " (date_creation, fk_user_author, numero, label)"; - $sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')"; + $sql .= " VALUES ('".$this->db->idate($now)."',".((int) $user->id).",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')"; - dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system"); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 99a0dc0dc48..50116b94b23 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro - * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2021 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France * * 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 @@ -26,6 +26,9 @@ * \brief File of class to manage accounting accounts */ +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; /** * Class to manage accounting accounts */ @@ -140,6 +143,11 @@ class AccountingAccount extends CommonObject */ public $reconcilable; + /** + * @var array cache array + */ + private $accountingaccount_codetotid_cache = array(); + /** * Constructor * @@ -150,7 +158,7 @@ class AccountingAccount extends CommonObject global $conf; $this->db = $db; - $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method + $this->next_prev_filter = "fk_pcg_version IN (SELECT pcg_version FROM ".MAIN_DB_PREFIX."accounting_system WHERE rowid=".((int) $conf->global->CHARTOFACCOUNTS).")"; // Used to add a filter in Form::showrefnav method } /** @@ -185,7 +193,7 @@ class AccountingAccount extends CommonObject $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; } - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -225,8 +233,8 @@ class AccountingAccount extends CommonObject /** * Insert new accounting account in chart of accounts * - * @param User $user User making action - * @param int $notrigger Disable triggers + * @param User $user User making action + * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ public function create($user, $notrigger = 0) @@ -259,7 +267,7 @@ class AccountingAccount extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_account("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account("; $sql .= "datec"; $sql .= ", entity"; $sql .= ", fk_pcg_version"; @@ -274,7 +282,7 @@ class AccountingAccount extends CommonObject $sql .= ", reconcilable"; $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", ".(empty($this->fk_pcg_version) ? 'NULL' : "'".$this->db->escape($this->fk_pcg_version)."'"); $sql .= ", ".(empty($this->pcg_type) ? 'NULL' : "'".$this->db->escape($this->pcg_type)."'"); $sql .= ", ".(empty($this->account_number) ? 'NULL' : "'".$this->db->escape($this->account_number)."'"); @@ -282,22 +290,22 @@ class AccountingAccount extends CommonObject $sql .= ", ".(empty($this->label) ? "''" : "'".$this->db->escape($this->label)."'"); $sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'"); $sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".(int) $this->active; $sql .= ", ".(int) $this->reconcilable; $sql .= ")"; $this->db->begin(); - dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; - $this->errors[] = "Error ".$this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_account"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account"); // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -313,8 +321,8 @@ class AccountingAccount extends CommonObject // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -327,7 +335,7 @@ class AccountingAccount extends CommonObject /** * Update record * - * @param User $user Use making update + * @param User $user Use making update * @return int <0 if KO, >0 if OK */ public function update($user) @@ -339,20 +347,20 @@ class AccountingAccount extends CommonObject $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; - $sql .= " SET fk_pcg_version = ".($this->fk_pcg_version ? "'".$this->db->escape($this->fk_pcg_version)."'" : "null"); - $sql .= " , pcg_type = ".($this->pcg_type ? "'".$this->db->escape($this->pcg_type)."'" : "null"); - $sql .= " , account_number = '".$this->db->escape($this->account_number)."'"; - $sql .= " , account_parent = ".(int) $this->account_parent; - $sql .= " , label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "''"); - $sql .= " , labelshort = ".($this->labelshort ? "'".$this->db->escape($this->labelshort)."'" : "''"); - $sql .= " , fk_accounting_category = ".(empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= " , fk_user_modif = ".((int) $user->id); - $sql .= " , active = ".(int) $this->active; - $sql .= " , reconcilable = ".(int) $this->reconcilable; - $sql .= " WHERE rowid = ".((int) $this->id); + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; + $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); + $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); + $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; + $sql .= " , account_parent = " . (int) $this->account_parent; + $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''"); + $sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''"); + $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category); + $sql .= " , fk_user_modif = " . ((int) $user->id); + $sql .= " , active = " . (int) $this->active; + $sql .= " , reconcilable = " . (int) $this->reconcilable; + $sql .= " WHERE rowid = " . ((int) $this->id); - dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->db->commit(); @@ -374,12 +382,12 @@ class AccountingAccount extends CommonObject global $langs; $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; - $sql .= " WHERE fk_code_ventilation=".$this->id.")"; + $sql .= " WHERE fk_code_ventilation=".((int) $this->id).")"; $sql .= "UNION"; $sql .= " (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facture_fourn_det"; - $sql .= " WHERE fk_code_ventilation=".$this->id.")"; + $sql .= " WHERE fk_code_ventilation=".((int) $this->id).")"; - dol_syslog(get_class($this)."::checkUsage sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::checkUsage", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -413,22 +421,22 @@ class AccountingAccount extends CommonObject $this->db->begin(); if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_account"; - $sql .= " WHERE rowid=".((int) $this->id); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account"; + $sql .= " WHERE rowid=" . ((int) $this->id); - dol_syslog(get_class($this)."::delete sql=".$sql); + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (!$resql) { $error++; - $this->errors[] = "Error ".$this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -444,20 +452,20 @@ class AccountingAccount extends CommonObject /** * Return clicable 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 account - * @param int $nourl 1=Disable url - * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) - * @param string $option 'ledger', 'journals', 'accountcard' - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $withlabel 0=No label, 1=Include label of account + * @param int $nourl 1=Disable url + * @param string $moretitle Add more text to title tooltip + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) + * @param string $option 'ledger', 'journals', 'accountcard' + * @return string String with URL */ public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { global $langs, $conf; - require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -465,15 +473,16 @@ class AccountingAccount extends CommonObject $result = ''; - $url = ''; $labelurl = ''; + $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($this->account_number) . '&search_accountancy_code_end=' . urlencode($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); + $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . urlencode($this->account_number) . '&search_accountancy_code_end=' . urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInJournals"); } elseif ($option == 'accountcard') { - $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.urlencode($this->id); + $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . urlencode($this->id); $labelurl = $langs->trans("ShowAccountingAccount"); } @@ -495,29 +504,29 @@ class AccountingAccount extends CommonObject $labeltoshow = $this->labelshort; } - $label = ''.$labelurl.''; + $label = '' . $labelurl . ''; if (!empty($this->account_number)) { - $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + $label .= '
' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); } if (!empty($labeltoshow)) { - $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + $label .= '
' . $langs->trans('Label') . ': ' . $labeltoshow; } if ($moretitle) { - $label .= ' - '.$moretitle; + $label .= ' - ' . $moretitle; } $linkclose = ''; if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $labelurl; - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; $linkclose .= ' class="classfortooltip"'; } - $linkstart = ''; + $linkstart = ''; $linkend = ''; if ($nourl) { @@ -528,17 +537,17 @@ class AccountingAccount extends CommonObject $label_link = length_accountg($this->account_number); if ($withlabel) { - $label_link .= ' - '.($nourl ? '' : '').$labeltoshow.($nourl ? '' : ''); + $label_link .= ' - ' . ($nourl ? '' : '') . $labeltoshow . ($nourl ? '' : ''); } if ($withpicto) { - $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); + $result .= ($linkstart . img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . $linkend); } if ($withpicto && $withpicto != 2) { $result .= ' '; } if ($withpicto != 2) { - $result .= $linkstart.$label_link.$linkend; + $result .= $linkstart . $label_link . $linkend; } return $result; } @@ -552,10 +561,10 @@ class AccountingAccount extends CommonObject public function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; - $sql .= ' WHERE a.rowid = '.((int) $id); + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; + $sql .= ' WHERE a.rowid = ' . ((int) $id); - dol_syslog(get_class($this).'::info sql='.$sql); + dol_syslog(get_class($this) . '::info sql=' . $sql); $result = $this->db->query($sql); if ($result) { @@ -584,8 +593,8 @@ class AccountingAccount extends CommonObject /** * Deactivate an account (for status active or status reconcilable) * - * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $id Id + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ public function accountDeactivate($id, $mode = 0) @@ -604,7 +613,7 @@ class AccountingAccount extends CommonObject $sql .= "SET ".$fieldtouse." = '0'"; $sql .= " WHERE rowid = ".((int) $id); - dol_syslog(get_class($this)."::accountDeactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::accountDeactivate ".$fieldtouse, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -620,15 +629,15 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Account activated * - * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $id Id + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function account_activate($id, $mode = 0) + public function accountActivate($id, $mode = 0) { // phpcs:enable $this->db->begin(); @@ -642,7 +651,7 @@ class AccountingAccount extends CommonObject $sql .= " SET ".$fieldtouse." = '1'"; $sql .= " WHERE rowid = ".((int) $id); - dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::account_activate ".$fieldtouse, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->db->commit(); @@ -654,12 +663,11 @@ class AccountingAccount extends CommonObject } } - /** * Retourne le libelle du statut d'un user (actif, inactif) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -670,9 +678,9 @@ class AccountingAccount extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { @@ -694,9 +702,9 @@ class AccountingAccount extends CommonObject } } elseif ($mode == 2) { if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled'); } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled'); } } elseif ($mode == 3) { if ($status == 1) { @@ -706,15 +714,206 @@ class AccountingAccount extends CommonObject } } elseif ($mode == 4) { if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled'); } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled'); } } elseif ($mode == 5) { if ($status == 1) { - return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); + return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4'); } elseif ($status == 0) { - return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5'); + } + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + + /** + * Return Suggest accounting accounts to bind + * + * @param Societe $buyer Societe Object Buyers + * @param $seller Company Object seller + * @param Product $product Product object sell or buy + * @param Facture $facture Facture + * @param FactureLigne $factureDet Facture Det + * @param array $accountingAccount array of Account account + * @param string $type Customer / Supplier + * + * @return array Accounting accounts suggested + */ + public function getAccountingCodeToBind(Societe $buyer, $seller, Product $product, Facture $facture, FactureLigne $factureDet, $accountingAccount = array(), $type = '') + { + global $conf; + global $hookmanager; + + // Instantiate hooks for external modules + $hookmanager->initHooks(array('accoutancyBindingCalculation')); + + // Execute hook accoutancyBindingCalculation + $parameters = array('buyer' => $buyer, 'seller' => $seller, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount'=>$accountingAccount, $type); + $reshook = $hookmanager->executeHooks('accoutancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks + + if (empty($reshook)) { + if ($type=='customer') { + $const_name = "SOLD"; + } elseif ($type=='supplier') { + $const_name = "BUY"; + } + + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $isBuyerInEEC = isInEEC($buyer); + $isSellerInEEC = isInEEC($seller); + $code_l = ''; + $code_p = ''; + $code_t = ''; + $suggestedid = ''; + + // Level 1: Search suggested default account for product/service + $suggestedaccountingaccountbydefaultfor = ''; + if ($factureDet->product_type == 1) { + if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT + $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number + $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_INTRA_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_INTRA_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { // Foreign sale + $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_EXPORT_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_EXPORT_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } + } elseif ($factureDet->product_type == 0) { + if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT + $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number + $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_INTRA_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_INTRA_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { + $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_EXPORT_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_EXPORT_ACCOUNT'} : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } + } + if ($code_l == -1) { + $code_l = ''; + } + + // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) + $suggestedaccountingaccountfor = ''; + if ((($buyer->country_code == $seller->country_code) || empty($buyer->country_code))) { + // If buyer in same country than seller (if not defined, we assume it is same country) + if ($type=='customer' && !empty($product->accountancy_code_sell)) { + $code_p = $product->accountancy_code_sell; + } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + $code_p = $product->accountancy_code_sell; + } + $suggestedid = $accountingAccount['dom']; + $suggestedaccountingaccountfor = 'prodserv'; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { + // European intravat sale, but with VAT + if ($type=='customer' && !empty($product->accountancy_code_sell)) { + $code_p = $product->accountancy_code_sell; + } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + $code_p = $product->accountancy_code_sell; + } + $suggestedid = $accountingAccount['dom']; + $suggestedaccountingaccountfor = 'eecwithvat'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { + // European intravat sale, without VAT intra community number + if ($type=='customer' && !empty($product->accountancy_code_sell)) { + $code_p = $product->accountancy_code_sell; + } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + $code_p = $product->accountancy_code_sell; + } + $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? + $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) { + // European intravat sale + if ($type=='customer' && !empty($product->accountancy_code_sell_intra)) { + $code_p = $product->accountancy_code_sell_intra; + } elseif ($type=='supplier' && !empty($product->accountancy_code_buy_intra)) { + $code_p = $product->accountancy_code_buy_intra; + } + $suggestedid = $accountingAccount['intra']; + $suggestedaccountingaccountfor = 'eec'; + } else { + // Foreign sale + // European intravat sale + if ($type=='customer' && !empty($product->accountancy_code_sell_export)) { + $code_p = $product->accountancy_code_sell_export; + } elseif ($type=='supplier' && !empty($product->accountancy_code_sell_export)) { + $code_p = $product->accountancy_code_sell_export; + } + $suggestedid = $accountingAccount['export']; + $suggestedaccountingaccountfor = 'export'; + } + } + + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + if (!empty($buyer->code_compta)) { + $code_t = $buyer->code_compta; + $suggestedid = $accountingAccount['thirdparty']; + $suggestedaccountingaccountfor = 'thridparty'; + } + } + + // Manage Deposit + if ($factureDet->desc == "(DEPOSIT)") { + $accountdeposittoventilated = new self($this->db); + $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + if ($result < 0) { + return -1; + } + + $code_l = $accountdeposittoventilated->ref; + $suggestedid = $accountdeposittoventilated->rowid; + $suggestedaccountingaccountfor = 'deposit'; + } + + if (empty($suggestedid) && empty($code_p) && !empty($code_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { + if (empty($this->accountingaccount_codetotid_cache[$code_l])) { + $tmpaccount = new self($this->db); + $result = $tmpaccount->fetch(0, $code_l, 1); + if ($result < 0) { + return -1; + } + if ($tmpaccount->id > 0) { + $suggestedid = $tmpaccount->id; + } + $this->accountingaccount_codetotid_cache[$code_l] = $tmpaccount->id; + } else { + $suggestedid = $this->accountingaccount_codetotid_cache[$code_l]; + } + } + return array( + 'suggestedaccountingaccountbydefaultfor' => $suggestedaccountingaccountbydefaultfor, + 'suggestedaccountingaccountfor' => $suggestedaccountingaccountfor, + 'suggestedid' => $suggestedid, + 'code_l' => $code_l, + 'code_p' => $code_p, + 'code_t' => $code_t, + ); + } else { + if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) { + return $hookmanager->resArray; } } } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 95a69466658..376178b45ba 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -113,7 +113,7 @@ class AccountingJournal extends CommonObject $sql .= " AND entity = ".$conf->entity; } - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -170,18 +170,18 @@ class AccountingJournal extends CommonObject $sql .= ' WHERE 1 = 1'; $sql .= " AND entity IN (".getEntity('accountancy').")"; if (count($sqlwhere) > 0) { - $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); + $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $this->lines = array(); - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 2c715aa9fd6..9cda04f6155 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -382,15 +382,15 @@ class BookKeeping extends CommonObject $sql .= ", '".$this->db->escape($this->numero_compte)."'"; $sql .= ", ".(!empty($this->label_compte) ? ("'".$this->db->escape($this->label_compte)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->label_operation)."'"; - $sql .= ", ".$this->debit; - $sql .= ", ".$this->credit; - $sql .= ", ".$this->montant; + $sql .= ", ".((float) $this->debit); + $sql .= ", ".((float) $this->credit); + $sql .= ", ".((float) $this->montant); $sql .= ", ".(!empty($this->sens) ? ("'".$this->db->escape($this->sens)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->fk_user_author)."'"; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->escape($this->code_journal)."'"; $sql .= ", ".(!empty($this->journal_label) ? ("'".$this->db->escape($this->journal_label)."'") : "NULL"); - $sql .= ", ".$this->db->escape($this->piece_num); + $sql .= ", ".((int) $this->piece_num); $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")"; @@ -647,7 +647,7 @@ class BookKeeping extends CommonObject $sql .= ' '.(!isset($this->credit) ? 'NULL' : $this->credit).','; $sql .= ' '.(!isset($this->montant) ? 'NULL' : $this->montant).','; $sql .= ' '.(!isset($this->sens) ? 'NULL' : "'".$this->db->escape($this->sens)."'").','; - $sql .= ' '.$user->id.','; + $sql .= ' '.((int) $user->id).','; $sql .= ' '."'".$this->db->idate($now)."',"; $sql .= ' '.(empty($this->code_journal) ? 'NULL' : "'".$this->db->escape($this->code_journal)."'").','; $sql .= ' '.(empty($this->journal_label) ? 'NULL' : "'".$this->db->escape($this->journal_label)."'").','; @@ -883,21 +883,21 @@ class BookKeeping extends CommonObject $sql .= ' WHERE 1 = 1'; $sql .= " AND entity IN (".getEntity('accountancy').")"; if (count($sqlwhere) > 0) { - $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); + $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } // Affichage par compte comptable if (!empty($option)) { $sql .= ' AND t.subledger_account IS NOT NULL'; - $sql .= ' ORDER BY t.subledger_account ASC'; + $sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : ''); + $sortorder = 'ASC'.($sortfield ? ','.$sortfield : ''); } else { - $sql .= ' ORDER BY t.numero_compte ASC'; + $sortfield = 't.numero_compte'.($sortfield ? ','.$sortfield : ''); + $sortorder = 'ASC'.($sortorder ? ','.$sortorder : ''); } - if (!empty($sortfield)) { - $sql .= ', '.$sortfield.' '.$sortorder; - } + $sql .= $this->db->order($sortfield, $sortorder); if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $resql = $this->db->query($sql); @@ -937,7 +937,6 @@ class BookKeeping extends CommonObject $line->piece_num = $obj->piece_num; $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_export = $this->db->jdate($obj->date_export); - $line->date_validation = $this->db->jdate($obj->date_validated); $line->date_validation = $this->db->jdate($obj->date_validation); $this->lines[] = $line; @@ -1043,13 +1042,13 @@ class BookKeeping extends CommonObject $sql .= " AND t.date_export IS NULL"; } if (count($sqlwhere) > 0) { - $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); + $sql .= ' AND '.implode(" ".$filtermode." ", $sqlwhere); } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $this->lines = array(); @@ -1090,7 +1089,6 @@ class BookKeeping extends CommonObject $line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $line->date_modification = $this->db->jdate($obj->date_modification); $line->date_export = $this->db->jdate($obj->date_export); - $line->date_validation = $this->db->jdate($obj->date_validated); $line->date_validation = $this->db->jdate($obj->date_validation); $this->lines[] = $line; @@ -1137,17 +1135,17 @@ class BookKeeping extends CommonObject if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; + $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; + $sqlwhere[] = $key."'".$this->db->idate($value)."'"; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; + $sqlwhere[] = $key."'".$this->db->escape($value)."'"; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key.'='.$value; + $sqlwhere[] = $key." = ".((int) $value); } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + $sqlwhere[] = $key." LIKE '".$this->db->escape($value)."%'"; } elseif ($key == 't.subledger_label') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + $sqlwhere[] = $key." LIKE '".$this->db->escape($value)."%'"; } elseif ($key == 't.code_journal' && !empty($value)) { if (is_array($value)) { $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); @@ -1155,13 +1153,13 @@ class BookKeeping extends CommonObject $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); } } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; } } } $sql .= ' WHERE entity IN ('.getEntity('accountancy').')'; if (count($sqlwhere) > 0) { - $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); + $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } $sql .= ' GROUP BY t.numero_compte'; @@ -1170,7 +1168,7 @@ class BookKeeping extends CommonObject $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $resql = $this->db->query($sql); @@ -1347,8 +1345,9 @@ class BookKeeping extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.$mode; - $sql .= ' SET '.$field.'='.(is_numeric($value) ? $value : "'".$this->db->escape($value)."'"); - $sql .= " WHERE piece_num = '".$this->db->escape($piece_num)."'"; + $sql .= " SET ".$field." = ".(is_numeric($value) ? ((float) $value) : "'".$this->db->escape($value)."'"); + $sql .= " WHERE piece_num = ".((int) $piece_num); + $resql = $this->db->query($sql); if (!$resql) { @@ -1637,7 +1636,7 @@ class BookKeeping extends CommonObject $sql .= ", date_export"; } $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; - $sql .= " WHERE piece_num = ".$piecenum; + $sql .= " WHERE piece_num = ".((int) $piecenum); $sql .= " AND entity IN (".getEntity('accountancy').")"; dol_syslog(__METHOD__, LOG_DEBUG); @@ -1678,7 +1677,7 @@ class BookKeeping extends CommonObject $sql = "SELECT MAX(piece_num)+1 as max FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this)."getNextNumMvt sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."getNextNumMvt", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -1718,7 +1717,7 @@ class BookKeeping extends CommonObject $sql .= ", date_export"; } $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; - $sql .= " WHERE piece_num = ".$piecenum; + $sql .= " WHERE piece_num = ".((int) $piecenum); $sql .= " AND entity IN (".getEntity('accountancy').")"; dol_syslog(__METHOD__, LOG_DEBUG); @@ -1751,7 +1750,6 @@ class BookKeeping extends CommonObject $line->date_creation = $obj->date_creation; $line->date_modification = $obj->date_modification; $line->date_export = $obj->date_export; - $line->date_validation = $obj->date_validated; $line->date_validation = $obj->date_validation; $this->linesmvt[] = $line; @@ -1816,7 +1814,6 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - $line->date_validation = $obj->date_validated; $line->date_validation = $obj->date_validation; $this->linesexport[] = $line; @@ -1858,7 +1855,7 @@ class BookKeeping extends CommonObject $sql .= ' SELECT doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'"; + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num); $resql = $this->db->query($sql); if (!$resql) { @@ -2017,7 +2014,7 @@ class BookKeeping extends CommonObject $sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'"; $sql .= " AND aa.entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_account", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; @@ -2057,7 +2054,7 @@ class BookKeeping extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " WHERE aa.entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_account", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index b2abf01948e..1dd4c4df3e5 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -279,7 +279,7 @@ class Lettering extends BookKeeping $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL "; $this->db->begin(); - dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index b612762d358..fdcc6f54ab3 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -63,7 +63,7 @@ if (empty($conf->accounting->enabled)) { if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->fiscalyear->write) { +if (empty($user->rights->accounting->fiscalyear->write)) { accessforbidden(); } @@ -95,7 +95,7 @@ if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting- $sql .= " AND doc_date >= '" . $db->idate($date_start) . "'"; $sql .= " AND doc_date <= '" . $db->idate($date_end) . "'"; - dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); + dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated", LOG_DEBUG); $result = $db->query($sql); if (!$result) { $error++; @@ -189,7 +189,7 @@ for ($i = 1; $i <= 12; $i++) { if ($j > 12) { $j -= 12; } - $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(b.doc_date)=".$j, "1", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; } $sql .= " COUNT(b.rowid) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; @@ -198,7 +198,7 @@ $sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; $sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy $sql .= " AND date_validated IS NULL"; -dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/closure/index.php', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index b3ce892b235..296d6729301 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -117,7 +117,7 @@ if (!empty($id)) { $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".((int) $id); $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/customer/card.php sql=".$sql, LOG_DEBUG); + dol_syslog("/accounting/customer/card.php", LOG_DEBUG); $result = $db->query($sql); if ($result) { diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0ee9c865603..23958820b64 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "accountancy")); @@ -42,10 +43,11 @@ if (empty($conf->accounting->enabled)) { if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->accounting->bind->write) { +if (empty($user->rights->accounting->bind->write)) { accessforbidden(); } +$accountingAccount = new AccountingAccount($db); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) { @@ -71,12 +73,23 @@ $action = GETPOST('action', 'aZ09'); $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->socid > 0) { + accessforbidden(); +} +if (empty($user->rights->accounting->mouvements->lire)) { + accessforbidden(); +} + /* * Actions */ -if ($action == 'clean' || $action == 'validatehistory') { +if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) { // Clean database $db->begin(); $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; @@ -85,8 +98,8 @@ if ($action == 'clean' || $action == 'validatehistory') { $sql1 .= ' (SELECT accnt.rowid '; $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity).')'; + $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.((int) $conf->entity).')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); @@ -110,13 +123,13 @@ if ($action == 'validatehistory') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; } else { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; }*/ @@ -163,6 +176,7 @@ if ($action == 'validatehistory') { } dol_syslog('htdocs/accountancy/customer/index.php'); + $result = $db->query($sql); if (!$result) { $error++; @@ -172,35 +186,74 @@ if ($action == 'validatehistory') { $isSellerInEEC = isInEEC($mysoc); + $thirdpartystatic = new Societe($db); + $facture_static = new Facture($db); + $facture_static_det = new FactureLigne($db); + $product_static = new Product($db); + $i = 0; while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); - $isBuyerInEEC = isInEEC($objp); // This make a database request but there is a cache into $conf->cache['country_code_in_EEC'] + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->tva_intra = $objp->tva_intra; + $thirdpartystatic->code_compta = $objp->company_code_sell; - // Level 2: Search suggested account for product/service (similar code exists in page list.php to make manual binding) - $suggestedaccountingaccountfor = ''; - if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = ''; + $product_static->ref = $objp->product_ref; + $product_static->id = $objp->product_id; + $product_static->type = $objp->type; + $product_static->label = $objp->product_label; + $product_static->status = $objp->status; + $product_static->status_buy = $objp->status_buy; + $product_static->accountancy_code_sell = $objp->code_sell; + $product_static->accountancy_code_sell_intra = $objp->code_sell_intra; + $product_static->accountancy_code_sell_export = $objp->code_sell_export; + $product_static->accountancy_code_buy = $objp->code_buy; + $product_static->accountancy_code_buy_intra = $objp->code_buy_intra; + $product_static->accountancy_code_buy_export = $objp->code_buy_export; + $product_static->tva_tx = $objp->tva_tx_prod; + + $facture_static->ref = $objp->ref; + $facture_static->id = $objp->facid; + $facture_static->type = $objp->ftype; + $facture_static->date = $objp->datef; + + $facture_static_det->id = $objp->rowid; + $facture_static_det->total_ht = $objp->total_ht; + $facture_static_det->tva_tx = $objp->tva_tx_line; + $facture_static_det->vat_src_code = $objp->vat_src_code; + $facture_static_det->product_type = $objp->type_l; + $facture_static_det->desc = $objp->description; + + $accountingAccountArray = array( + 'dom'=>$objp->aarowid, + 'intra'=>$objp->aarowid_intra, + 'export'=>$objp->aarowid_export, + 'thirdparty' =>$objp->aarowid_thirdparty); + + $code_sell_p_notset = ''; + $code_sell_t_notset = ''; + + $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accountingAccountArray, 'customer'); + if (!is_array($return) && $return<0) { + setEventMessage($accountingAccount->error, 'errors'); } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding - $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_p = $objp->code_sell_intra; - $objp->aarowid_suggest = $objp->aarowid_intra; - $suggestedaccountingaccountfor = 'eec'; - } else { // Foreign sale - $objp->code_sell_p = $objp->code_sell_export; - $objp->aarowid_suggest = $objp->aarowid_export; - $suggestedaccountingaccountfor = 'export'; + $suggestedid=$return['suggestedid']; + $suggestedaccountingaccountfor=$return['suggestedaccountingaccountfor']; + + if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') { + $suggestedid=$return['suggestedid']; + } else { + $suggestedid=0; } } @@ -215,8 +268,8 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); + $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid); + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $facture_static_det->id); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { @@ -260,13 +313,13 @@ $y = $year_current; $buttonbind = ''.$langs->trans("ValidateHistory").''; -print_barre_liste($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, $buttonbind, '', 0, 1, 1); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
'; print ''; print ''; -print ''; +print ''; for ($i = 1; $i <= 12; $i++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; if ($j > 12) { @@ -283,7 +336,7 @@ for ($i = 1; $i <= 12; $i++) { if ($j > 12) { $j -= 12; } - $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j, "fd.total_ht", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; @@ -306,7 +359,7 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; -dol_syslog('htdocs/accountancy/customer/index.php sql='.$sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/customer/index.php', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -319,7 +372,7 @@ if ($resql) { print length_accountg($row[0]); } print ''; - print ''."\n"; print ''; print ''; print '"; -print ''; +print ''; print ''; print '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans("Label").''; + print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else { @@ -344,13 +397,13 @@ print ''; print '
'; -print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); +print_barre_liste(img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print ''; print ''; -print ''; +print ''; for ($i = 1; $i <= 12; $i++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; if ($j > 12) { @@ -367,7 +420,7 @@ for ($i = 1; $i <= 12; $i++) { if ($j > 12) { $j -= 12; } - $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j, "fd.total_ht", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; @@ -404,7 +457,7 @@ if ($resql) { } print ''; - print ''; + } + } + print '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans("Label").''; + print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else { @@ -452,7 +505,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange if ($j > 12) { $j -= 12; } - $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j, "fd.total_ht", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; @@ -513,7 +566,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange if ($j > 12) { $j -= 12; } - $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j, "(fd.total_ht-(fd.qty * fd.buy_price_ht))", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; } $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 1e7c38b2607..7f09e111a23 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -191,7 +191,14 @@ print ''; + } + } elseif ($val['type'] == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + } + } else { + print ''; + } + print '
'; + + print '
'; + print ''; + print '
'; + + print ''; + print '
'; +} else { + if (!empty($arrayofparameters)) { + print ''; + print ''; + + foreach ($arrayofparameters as $constname => $val) { + if ($val['enabled']==1) { + $setupnotempty++; + print ''; + } + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print $form->textwithpicto($langs->trans($constname), $tooltiphelp); + print ''; + + if ($val['type'] == 'textarea') { + print dol_nl2br($conf->global->{$constname}); + } elseif ($val['type']== 'html') { + print $conf->global->{$constname}; + } elseif ($val['type'] == 'yesno') { + print ajax_constantonoff($constname); + } elseif (preg_match('/emailtemplate:/', $val['type'])) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $tmp = explode(':', $val['type']); + + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + if ($template<0) { + setEventMessages(null, $formmail->errors, 'errors'); + } + print $langs->trans($template->label); + } elseif (preg_match('/category:/', $val['type'])) { + $c = new Categorie($db); + $result = $c->fetch($conf->global->{$constname}); + if ($result < 0) { + setEventMessages(null, $c->errors, 'errors'); + } + $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text + $toprint = array(); + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; + } + print '
      ' . implode(' ', $toprint) . '
    '; + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } + } elseif ($val['type'] == 'product') { + $product = new Product($db); + $resprod = $product->fetch($conf->global->{$constname}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + setEventMessages(null, $object->errors, "errors"); + } + } else { + print $conf->global->{$constname}; + } + print '
    '; + + print '
    '; + print ''.$langs->trans("Modify").''; + print '
    '; + } else { + print '
    '.$langs->trans("NothingToSetup"); + } +} + + +if (empty($setupnotempty)) { + print '
    '.$langs->trans("NothingToSetup"); +} + +// Page end +print dol_get_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index cf4c250a678..697f8fa2130 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Alexandre Spangaro * * 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 @@ -43,12 +44,12 @@ if (!$user->admin) { $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search +$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'other'; // 'template', 'dashboard', 'login', 'other' + if (!defined("MAIN_MOTD")) { define("MAIN_MOTD", ""); } - - /* * Action */ @@ -94,168 +95,177 @@ if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKG } if ($action == 'update') { - dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_MULTILANGS", GETPOST("MAIN_MULTILANGS"), 'chaine', 0, '', $conf->entity); + $error = 0; - dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); + if ($mode == 'template') { + dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); - /*$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); - if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); - else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ + /*$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); + if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); + else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); + } + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); + } + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); + } else { + dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); + } + + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); + } else { + dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); + } } - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + if ($mode == 'dashboard') { + dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'restricthtml')), 'chaine', 0, '', $conf->entity); } - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + if ($mode == 'other') { + dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + + dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity); + + //dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", GETPOST("MAIN_DISABLE_JAVASCRIPT", 'aZ09'), 'chaine', 0, '', $conf->entity); + //dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", GETPOST("MAIN_BUTTON_HIDE_UNAUTHORIZED", 'aZ09'), 'chaine', 0, '', $conf->entity); + //dolibarr_set_const($db, "MAIN_MENU_HIDE_UNAUTHORIZED", GETPOST("MAIN_MENU_HIDE_UNAUTHORIZED", 'aZ09'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_START_WEEK", GETPOST("MAIN_START_WEEK", 'int'), 'chaine', 0, '', $conf->entity); + + dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", GETPOST("MAIN_DEFAULT_WORKING_DAYS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + + dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST("MAIN_BUGTRACK_ENABLELINK", 'alpha'), 'chaine', 0, '', $conf->entity); + + dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity); } - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); - } + if ($mode == 'login') { + dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'restricthtml')), 'chaine', 0, '', $conf->entity); + //dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); - } + $varforimage = 'imagebackground'; + $dirforimage = $conf->mycompany->dir_output . '/logos/'; + if ($_FILES[$varforimage]["tmp_name"]) { + $reg = array(); + if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { + $original_file = $reg[1]; - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); - } - - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity); - } - - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); - } - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); - } - - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); - } - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); - } - - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); - } else { - dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); - } - - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); - } else { - dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); - } - - $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); - if ($val == '') { - dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); - } else { - dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); - } - - dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity); - - //dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", GETPOST("MAIN_DISABLE_JAVASCRIPT", 'aZ09'), 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", GETPOST("MAIN_BUTTON_HIDE_UNAUTHORIZED", 'aZ09'), 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_MENU_HIDE_UNAUTHORIZED", GETPOST("MAIN_MENU_HIDE_UNAUTHORIZED", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_START_WEEK", GETPOST("MAIN_START_WEEK", 'int'), 'chaine', 0, '', $conf->entity); - - dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", GETPOST("MAIN_DEFAULT_WORKING_DAYS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - - dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST("MAIN_BUGTRACK_ENABLELINK", 'alpha'), 'chaine', 0, '', $conf->entity); - - dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity); - - dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'restricthtml')), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'restricthtml')), 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities - - $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; - if ($_FILES[$varforimage]["tmp_name"]) { - $reg = array(); - if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { - $original_file = $reg[1]; - - $isimage = image_format_supported($original_file); - if ($isimage >= 0) { - dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); - if (!is_dir($dirforimage)) { - dol_mkdir($dirforimage); - } - $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); - if ($result > 0) { - dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity); - } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { - $error++; - $langs->load("errors"); - $tmparray = explode(':', $result); - setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); + $isimage = image_format_supported($original_file); + if ($isimage >= 0) { + dol_syslog("Move file " . $_FILES[$varforimage]["tmp_name"] . " to " . $dirforimage . $original_file); + if (!is_dir($dirforimage)) { + dol_mkdir($dirforimage); + } + $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage . $original_file, 1, 0, $_FILES[$varforimage]['error']); + if ($result > 0) { + dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity); + } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { + $error++; + $langs->load("errors"); + $tmparray = explode(':', $result); + setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); + } else { + $error++; + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } } else { $error++; - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + $langs->load("errors"); + setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); } - } else { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); } } } + $_SESSION["mainmenu"] = ""; // The menu manager may have changed - - $_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer - - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(GETPOSTISSET('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); exit; } @@ -274,6 +284,7 @@ $formadmin = new FormAdmin($db); print load_fiche_titre($langs->trans("GUISetup"), '', 'title_setup'); print ''.$langs->trans("DisplayDesc")."
    \n"; +print "
    \n"; //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -282,242 +293,347 @@ print '
    '; print ''; print ''; +print ''; + +$head = ihm_prepare_head(); + +print dol_get_fiche_head($head, $mode, '', -1, ''); + +print '
    '; clearstatcache(); -print '
    '; -print '
    '; -print ''; -print ''; -print ''; - -// Default language -print ''; -print ''; - -// Multilingual GUI -print ''; -print ''; - -print '
    '.img_picto('', 'language').' '.$langs->trans("Language").'
    '.$langs->trans("DefaultLanguage").''; -print img_picto('', 'language', 'class="pictofixedwidth"'); -print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, null, '', 0, 0, 'minwidth300', 2); -//print ''; -print '
    '.$langs->trans("EnableMultilangInterface").''; -print ajax_constantonoff("MAIN_MULTILANGS", array(), $conf->entity, 0, 0, 1, 0); -print '
    '."\n"; -print '
    '; - -print '
    '; -print '
    '; -print ''; -print '
    '; - -print '

    '; - -// Themes and themes options -showSkins(null, 1); -print '
    '; -print '
    '; -print ''; -print '
    '; - -print '

    '; - -// Other -print '
    '; -print ''; -print ''; -print ''; -print ''; - -// Disable javascript and ajax -print ''; -print ''; -print ''; - -// Max size of lists -print ''; -print ''; -print ''; - -// Max size of short lists on customer card -print ''; -print ''; -print ''; - -// show input border -/* - print ''; - print ''; - print ''; - */ - -// First day for weeks -print ''; -print ''; -print ''; - -// DefaultWorkingDays -print ''; -print ''; -print ''; - -// DefaultWorkingHours -print ''; -print ''; -print ''; - -// Firstname/Name -print ''; -print ''; -print ''; - -// Hide unauthorized menus -print ''; -print ''; -print ''; - -// Hide unauthorized button -print ''; -print ''; -print ''; - -// Hide version link -/* - -print ''; -print ''; -print ''; -*/ - -// Show bugtrack link -print ''; -print ''; -print ''; - -// Hide wiki link on login page -$pictohelp = ''; -print ''; -print ''; -print ''; - -// Message of the day on home page -$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); -complete_substitutions_array($substitutionarray, $langs); - -print ''; -print '
    '.$langs->trans("Miscellaneous").' '; -print '
    '.$langs->trans("DisableJavascript").''; -print ajax_constantonoff("MAIN_DISABLE_JAVASCRIPT", array(), $conf->entity, 0, 0, 1, 0); -print '     '.$langs->trans("DisableJavascriptNote").''; -print ''; -print '
    '.$langs->trans("DefaultMaxSizeList").' 
    '.$langs->trans("DefaultMaxSizeShortList").' 
    '.$langs->trans("showInputBorder").''; - print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1); - print ' 
    '.$langs->trans("WeekStartOnDay").''; -print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); -print ' 
    '.$langs->trans("DefaultWorkingDays").''; -print ''; -print ' 
    '.$langs->trans("DefaultWorkingHours").''; -print ''; -print ' 
    '.$langs->trans("FirstnameNamePosition").''; -$array = array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); -print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); -print ' 
    '.$langs->trans("HideUnauthorizedMenu").''; -//print $form->selectyesno('MAIN_MENU_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_MENU_HIDE_UNAUTHORIZED : 0, 1); -print ajax_constantonoff("MAIN_MENU_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0); -print ' 
    '.$langs->trans("ButtonHideUnauthorized").''; -//print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1); -print ajax_constantonoff("MAIN_BUTTON_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0); -print ' 
    '.$langs->trans("HideVersionLink").''; -print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1); -print ' 
    '.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).''; -print ''; -print ' 
    '.str_replace('{picto}', $pictohelp, $langs->trans("DisableLinkToHelp", '{picto}')).''; -print ajax_constantonoff("MAIN_HELP_DISABLELINK", array(), $conf->entity, 0, 0, 1, 0); -//print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1); -print ' 
    '; -$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
    '; -foreach ($substitutionarray as $key => $val) { - $texthelp .= $key.'
    '; +if ($mode == 'template') { + // Themes and themes options + showSkins(null, 1); } -print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); -print '
    '; +if ($mode == 'dashboard') { + print '
    '; + print ''; -$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD) ? $conf->global->MAIN_MOTD : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); -$doleditor->Create(); + // Message of the day on home page + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); + complete_substitutions_array($substitutionarray, $langs); -print ''."\n"; - -print '
    '."\n"; -print '
    '; - -print '
    '; - -print '
    '; -print ''; -print '
    '; - -print '

    '; - -// Other -print '
    '; -print ''; -print ''; -print ''; -print ''; -print ''; - -// Hide helpcenter link on login page -print ''; -print ''; -print ''; - -// Message on login page -$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount', 'user')); -complete_substitutions_array($substitutionarray, $langs); -print ''."\n"; - -// Background -print '' . "\n"; + + /* no more need for this option. It is now a widget already controlled by end user + print ''; + print ''; + */ + + print '
    '.$langs->trans("LoginPage").' 
    '.$langs->trans("DisableLinkToHelpCenter").''; -print ajax_constantonoff("MAIN_HELPCENTER_DISABLELINK", array(), $conf->entity, 0, 0, 0, 0); -print ' 
    '; -$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
    '; -foreach ($substitutionarray as $key => $val) { - $texthelp .= $key.'
    '; -} -print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); -print '
    '; -$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME) ? $conf->global->MAIN_HOME : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); -$doleditor->Create(); -print '
    '; -print '
    '; -$disabled = ''; -if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { - $disabled = ' disabled="disabled"'; -} -print ''; -if ($disabled) { - print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') '; -} -if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { - print ''.img_delete($langs->trans("Delete")).''; - if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) { - print '   '; - print ''; + print '
    '; + $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '
    '; + foreach ($substitutionarray as $key => $val) { + $texthelp .= $key . '
    '; } -} else { - print ''; + print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); + + print '
    '; + + $doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD) ? $conf->global->MAIN_MOTD : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); + $doleditor->Create(); + + print '
    ' . $langs->trans('BoxstatsDisableGlobal') . ''; + print ajax_constantonoff("MAIN_DISABLE_GLOBAL_BOXSTATS", array(), $conf->entity, 0, 0, 1, 0); + print '
    '; + print '
    '; + + print '
    '; + + print '
    '; + print ''; + + print ''; + + print ''; + print ''; + + if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { + // Block meteo + print ''; + print ''; + + // Block agenda + print ''; + print ''; + + // Block agenda + print ''; + print ''; + + // Block customer + print ''; + print ''; + + // Block supplier + print ''; + print ''; + + // Block contract + print ''; + print ''; + + // Block ticket + print ''; + print ''; + + // Block bank + print ''; + print ''; + + // Block adherent + print ''; + print ''; + + // Block expense report + print ''; + print ''; + + // Block holiday + print ''; + print ''; + } + + print '
    '; + print $langs->trans("DashboardDisableBlocks"); + print ''; + print '
    ' . $langs->trans('DashboardDisableGlobal') . ''; + print ajax_constantonoff("MAIN_DISABLE_GLOBAL_WORKBOARD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('MAIN_DISABLE_METEO') . ''; + print ajax_constantonoff("MAIN_DISABLE_METEO", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockAgenda') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_AGENDA", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockProject') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_PROJECT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockCustomer') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockSupplier') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_SUPPLIER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockContract') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_CONTRACT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockTicket') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_TICKET", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockBank') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_BANK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockAdherent') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_ADHERENT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockExpenseReport') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_EXPENSEREPORT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . $langs->trans('DashboardDisableBlockHoliday') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_HOLIDAY", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
    ' . "\n"; + print '
    '; } -print ''; -print '
    '."\n"; -print '
    '; +if ($mode == 'other') { + print '
    '; + print ''; + + print ''; + + // Default language + print ''; + print ''; + + // Multilingual GUI + print ''; + print ''; + + print '
    '; + print $langs->trans("Language"); + print ''; + print '
    '.$langs->trans("DefaultLanguage").''; + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, null, '', 0, 0, 'minwidth300', 2); + //print ''; + print '
    ' . $langs->trans("EnableMultilangInterface") . ''; + print ajax_constantonoff("MAIN_MULTILANGS", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'language'); + print '
    ' . "\n"; + print '
    '; + + print '
    '; + print ''; + print '
    '; + + print '
    '; + print '
    '; + + // Other + print '
    '; + print ''; + + print ''; + + // Max size of lists + print ''; + print ''; + print ''; + + // Max size of short lists on customer card + print ''; + print ''; + print ''; + + // show input border + /* + print ''; + print ''; + print ''; + */ + + // First day for weeks + print ''; + print ''; + print ''; + + // DefaultWorkingDays + print ''; + print ''; + print ''; + + // DefaultWorkingHours + print ''; + print ''; + print ''; + + // Firstname/Name + print ''; + print ''; + print ''; + + // Hide unauthorized menus + print ''; + print ''; + print ''; + + // Hide unauthorized button + print ''; + print ''; + print ''; + + // Hide version link + /* + + print ''; + print ''; + print ''; + */ + + // Show bugtrack link + print ''; + print ''; + print ''; + + // Hide wiki link on login page + $pictohelp = ''; + print ''; + print ''; + print ''; + + // Disable javascript and ajax + print ''; + print ''; + print ''; + + print '
    '; + print $langs->trans("Miscelaneous"); + print ''; + print '
    ' . $langs->trans("DefaultMaxSizeList") . ' 
    ' . $langs->trans("DefaultMaxSizeShortList") . ' 
    '.$langs->trans("showInputBorder").''; + print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1); + print ' 
    ' . $langs->trans("WeekStartOnDay") . ''; + print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); + print ' 
    ' . $langs->trans("DefaultWorkingDays") . ''; + print ''; + print ' 
    ' . $langs->trans("DefaultWorkingHours") . ''; + print ''; + print ' 
    ' . $langs->trans("FirstnameNamePosition") . ''; + $array = array(0 => $langs->trans("Firstname") . ' ' . $langs->trans("Lastname"), 1 => $langs->trans("Lastname") . ' ' . $langs->trans("Firstname")); + print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); + print ' 
    ' . $langs->trans("HideUnauthorizedMenu") . ''; + //print $form->selectyesno('MAIN_MENU_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_MENU_HIDE_UNAUTHORIZED : 0, 1); + print ajax_constantonoff("MAIN_MENU_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); + print ' 
    ' . $langs->trans("ButtonHideUnauthorized") . ''; + //print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1); + print ajax_constantonoff("MAIN_BUTTON_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); + print ' 
    '.$langs->trans("HideVersionLink").''; + print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1); + print ' 
    '; + print $form->textwithpicto($langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")), $langs->trans("ShowBugTrackLinkDesc")); + print ''; + print ''; + print ' 
    ' . str_replace('{picto}', $pictohelp, $langs->trans("DisableLinkToHelp", '{picto}')) . ''; + print ajax_constantonoff("MAIN_HELP_DISABLELINK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); + //print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1); + print ' 
    ' . $langs->trans("DisableJavascript") . ''; + print ajax_constantonoff("MAIN_DISABLE_JAVASCRIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); + print ' ' . $langs->trans("DisableJavascriptNote") . ''; + print ''; + print '
    ' . "\n"; + print '
    '; +} + +if ($mode == 'login') { + // Other + print '
    '; + print ''; + + print ''; + + // Hide helpcenter link on login page + print ''; + print ''; + + // Message on login page + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount', 'user')); + complete_substitutions_array($substitutionarray, $langs); + print '' . "\n"; + + // Background + print ''; + + print '
    '; + print $langs->trans("Parameter"); + print ''; + print $langs->trans("Value"); + print '
    ' . $langs->trans("DisableLinkToHelpCenter") . ''; + print ajax_constantonoff("MAIN_HELPCENTER_DISABLELINK", array(), $conf->entity, 0, 0, 0, 0, 0, 0, '', 'login'); + print '
    '; + $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '
    '; + foreach ($substitutionarray as $key => $val) { + $texthelp .= $key . '
    '; + } + print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); + print '
    '; + $doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME) ? $conf->global->MAIN_HOME : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); + $doleditor->Create(); + print '
    '; + print '
    '; + $disabled = ''; + if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { + $disabled = ' disabled="disabled"'; + } + print ''; + if ($disabled) { + print '(' . $langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND") . ') '; + } + if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { + print '' . img_delete($langs->trans("Delete")) . ''; + if (file_exists($conf->mycompany->dir_output . '/logos/' . $conf->global->MAIN_LOGIN_BACKGROUND)) { + print '   '; + print ''; + } + } else { + print ''; + } + print '
    '; + print '
    ' . "\n"; + print '
    '; +} -print '
    '; print '
    '; -print ''; +print ''; print '
    '; print '
    '; diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php index 38f8ae7554b..27e05e86143 100644 --- a/htdocs/admin/import.php +++ b/htdocs/admin/import.php @@ -87,7 +87,7 @@ print '
    '.$langs->trans("ImportCsvSeparator").' ('.$langs->trans("ByDefault").')'."global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE)."\">
    '; diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 396570b2155..daf20ce5aa2 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -51,6 +51,7 @@ if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
    ', $conf->global->MAIN_MOTD_SETUPPAGE); if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { $i = 0; + $reg = array(); while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) { $tmp = explode('|', $reg[1]); if (!empty($tmp[1])) { @@ -81,7 +82,9 @@ print '

    '; if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { $setupcompanynotcomplete = 1; } -print img_picto('', 'company', 'class="paddingright"').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); +print img_picto('', 'company', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit&token='.newToken()), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); +print '

    '; +print $langs->trans("SetupDescription3b"); if (!empty($setupcompanynotcomplete)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); @@ -90,9 +93,11 @@ if (!empty($setupcompanynotcomplete)) { print '
    '; print '
    '; print '
    '; +print '
    '; // Show info setup module -print img_picto('', 'cog', 'class="paddingright"').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); +print img_picto('', 'cog', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); +print '

    '.$langs->trans("SetupDescription4b"); if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); @@ -109,8 +114,8 @@ $reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $act print $hookmanager->resPrint; if (empty($reshook)) { // Show into other - print ''.$langs->trans("SetupDescription5")."
    "; - print "
    "; + print ''.$langs->trans("SetupDescription5")."
    "; + print '
    '; // Show logo print '
    '; diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index b8434773f67..8d93c16741a 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -17,7 +17,7 @@ */ /** - * \file knowledgemanagement/admin/setup.php + * \file htdocs/admin/knowledgemanagement.php * \ingroup knowledgemanagement * \brief KnowledgeManagement setup page. */ @@ -65,9 +65,7 @@ if (!$user->admin) { * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { $maskconstorder = GETPOST('maskconstorder', 'alpha'); @@ -258,9 +256,7 @@ if ($action == 'edit') { } print ''; - print '
    '; - print ''; - print '
    '; + print $form->buttonsSaveCancel("Save", ''); print ''; print '
    '; @@ -326,7 +322,7 @@ if ($action == 'edit') { print ''; print ''; } else { //print '
    '.$langs->trans("NothingToSetup"); @@ -398,7 +394,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $langs->load("errors"); print '
    '.$langs->trans($tmp).'
    '; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } @@ -535,13 +531,13 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Active if (in_array($name, $def)) { print ''."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''; } else { print ''."\n"; - print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print ""; } diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index b606a986ba2..4010d724c1a 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2006-2020 Laurent Destailleur - * Copyright (C) 2011-2013 Juanjo Menent +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2006-2020 Laurent Destailleur + * Copyright (C) 2011-2013 Juanjo Menent * * 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 @@ -131,7 +131,7 @@ if (!function_exists("ldap_connect")) { $form = new Form($db); -print '
    '; +print ''; print ''; print dol_get_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"), -1); @@ -153,7 +153,7 @@ $arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP"); print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE); print ''.$langs->trans("LDAPDnSynchroActiveExample").''; if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) { - print '
    '.$langs->trans("LDAPSetupNotComplete").''; + print '
    '.$langs->trans("LDAPSetupNotComplete").''; } print ''; @@ -275,7 +275,7 @@ print ''; print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print '
    '; @@ -297,24 +297,24 @@ if (function_exists("ldap_connect")) { if ($result > 0) { // Test ldap connect and bind print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).''; + print ''.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).''; print '
    '; if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS)) { if ($result == 2) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPBindOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; + print ''.$langs->trans("LDAPBindOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPBindKO", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; + print ''.$langs->trans("LDAPBindKO", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
    '; print $langs->trans("Error").' '.$ldap->error; print '
    '; } } else { print img_picto('', 'warning').' '; - print ''.$langs->trans("LDAPNoUserOrPasswordProvidedAccessIsReadOnly").''; + print ''.$langs->trans("LDAPNoUserOrPasswordProvidedAccessIsReadOnly").''; print '
    '; } @@ -322,18 +322,18 @@ if (function_exists("ldap_connect")) { // Test ldap_getversion if (($ldap->getVersion() == 3)) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSetupForVersion3").''; + print ''.$langs->trans("LDAPSetupForVersion3").''; print '
    '; } else { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSetupForVersion2").''; + print ''.$langs->trans("LDAPSetupForVersion2").''; print '
    '; } $unbind = $ldap->unbind(); } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPTCPConnectKO", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).''; + print ''.$langs->trans("LDAPTCPConnectKO", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).''; print '
    '; print $langs->trans("Error").' '.$ldap->error; print '
    '; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 4fb58898a07..fef3882d2ff 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -145,7 +145,7 @@ print dol_get_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescContact").'
    '; print '
    '; -print '
    '; +print ''; print ''; print ''; @@ -284,7 +284,7 @@ print info_admin($langs->trans("LDAPDescValues")); print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; @@ -321,12 +321,12 @@ if (function_exists("ldap_connect")) { if ($result2 > 0) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSynchroOK").'
    '; + print ''.$langs->trans("LDAPSynchroOK").'
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); + print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } @@ -336,9 +336,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 19d24ecd5db..82ee85b9a20 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -120,7 +120,7 @@ print $langs->trans("LDAPDescGroups").'
    '; print '
    '; -print ''; +print ''; print ''; print '
    '; @@ -210,7 +210,7 @@ print info_admin($langs->trans("LDAPDescValues")); print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; @@ -260,12 +260,12 @@ if (function_exists("ldap_connect")) { if ($result2 > 0) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSynchroOK").'
    '; + print ''.$langs->trans("LDAPSynchroOK").'
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); + print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } @@ -275,9 +275,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } @@ -331,9 +331,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index ab1af5fcf16..876c31d79b1 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -184,7 +184,7 @@ if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -print ''; +print ''; print ''; print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); @@ -433,7 +433,7 @@ print info_admin($langs->trans("LDAPDescValues")); print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; @@ -472,12 +472,12 @@ if (function_exists("ldap_connect")) { if ($result2 > 0) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSynchroOK").'
    '; + print ''.$langs->trans("LDAPSynchroOK").'
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); + print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } @@ -487,9 +487,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index ae4a1794f35..05572dc8bbf 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -112,7 +112,7 @@ print $langs->trans("LDAPDescMembersTypes").'
    '; print '
    '; -print ''; +print ''; print ''; $form = new Form($db); @@ -180,7 +180,7 @@ print info_admin($langs->trans("LDAPDescValues")); print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; @@ -223,12 +223,12 @@ if (function_exists("ldap_connect")) { if ($result2 > 0) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSynchroOK").'
    '; + print ''.$langs->trans("LDAPSynchroOK").'
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); + print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } @@ -238,9 +238,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 6e38eb2564e..e6041650d63 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -173,7 +173,7 @@ if (!function_exists("ldap_connect")) { } -print ''; +print ''; print ''; @@ -397,7 +397,7 @@ print info_admin($langs->trans("LDAPDescValues")); print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; @@ -444,12 +444,12 @@ if (function_exists("ldap_connect")) { if ($result2 > 0) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPSynchroOK").'
    '; + print ''.$langs->trans("LDAPSynchroOK").'
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); + print ''.$langs->trans("LDAPSynchroKOMayBePermissions"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } @@ -459,9 +459,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } @@ -530,9 +530,9 @@ if (function_exists("ldap_connect")) { print "\n
    "; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPSynchroKO"); + print ''.$langs->trans("LDAPSynchroKO"); print ': '.$ldap->error; - print '
    '; + print '
    '; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'
    '; } } diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 4a599499053..6246f9c09c3 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -108,9 +108,9 @@ $aCurrencies = array($conf->currency); // Default currency always first position if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; - $sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency'; - $sql .= ' WHERE entity = '.$conf->entity; - $sql .= ' AND code != "'.$conf->currency.'"'; // Default currency always first position + $sql = "SELECT rowid, code FROM ".MAIN_DB_PREFIX."multicurrency"; + $sql .= " WHERE entity = ".((int) $conf->entity); + $sql .= " AND code <> '".$db->escape($conf->currency)."'"; // Default currency always first position $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { @@ -190,7 +190,7 @@ if ($action == 'edit') { print ''; print ''; } diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index 94b0da08d4f..59b7eb8b463 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -105,7 +105,7 @@ foreach ($list as $key) { // Value print ''; print ''; print "
    '; if (!empty($conf->accounting->enabled)) { - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1); } else { print ''; } @@ -117,7 +117,7 @@ print '
    \n"; -print '
    '; +print '
    '; // End of page llxFooter(); diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 7988c0dab7f..37735a43ed3 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -193,8 +193,7 @@ if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >= print ''; -print '
    '; -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 15dcccdb000..8b003ce2d4e 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -218,7 +218,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { print ''; print $langs->trans("TestSubscribe").'
    '; - print $langs->trans("EMail").'
    '; + print $langs->trans("EMail").'
    '; print ''; @@ -227,7 +227,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { print ''; print $langs->trans("TestUnSubscribe").'
    '; - print $langs->trans("EMail").'
    '; + print $langs->trans("EMail").'
    '; print ''; } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index e86c78763ee..9c5418ac19d 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -292,7 +292,7 @@ if ($action == 'edit') { print dol_get_fiche_head($head, 'common', '', -1); print ''.$langs->trans("EMailsDesc")."
    \n"; - print "
    \n"; + print "

    \n"; clearstatcache(); @@ -536,18 +536,14 @@ if ($action == 'edit') { print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; } else { print dol_get_fiche_head($head, 'common', '', -1); print ''.$langs->trans("EMailsDesc")."
    \n"; - print "
    \n"; + print "

    \n"; print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; @@ -788,7 +784,7 @@ if ($action == 'edit') { // Actions button print '
    '; - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) { diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 511f5dde698..015b943ac04 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -243,7 +243,7 @@ if ($action == 'edit') { print dol_get_fiche_head($head, 'common_emailing', '', -1); print ''.$langs->trans("EMailsDesc")."
    \n"; - print "
    \n"; + print "

    \n"; clearstatcache(); @@ -405,18 +405,14 @@ if ($action == 'edit') { print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; } else { print dol_get_fiche_head($head, 'common_emailing', '', -1); print ''.$langs->trans("EMailsDesc")."
    \n"; - print "
    \n"; + print "

    \n"; print '
    '; print ''; @@ -519,7 +515,7 @@ if ($action == 'edit') { print '
    '; - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || !$linuxlike) { diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index d8c827337ad..d3441cf2e21 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -226,12 +226,12 @@ print "
    \n"; // -------------------------------------------------------------------- $sql = 'SELECT '; foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; + $sql .= "t.".$key.", "; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); } } // Add fields from hooks @@ -282,7 +282,7 @@ $sql .= $hookmanager->resPrint; $sql.= " GROUP BY " foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= "t.".$key.", "; } // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { @@ -395,12 +395,8 @@ if ($action != 'create') { print $form->selectarray('active', $object->fields['active']['arrayofkeyval'], (GETPOSTISSET('active') ? GETPOST('active', 'int') : $object->active), 0, 0, 0, '', 1); print ''; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - print '
    '; - print '
    '; - print ''; - print '   '; - print ''; - print '
    '; + + print $form->buttonsSaveCancel(); } } else { /*print '
    '; @@ -428,12 +424,8 @@ if ($action != 'create') { print $form->selectarray('active', $object->fields['active']['arrayofkeyval'], GETPOST('active', 'int'), 0); print ''; print ''; - print '
    '; - print '
    '; - print ''; - print '   '; - print ''; - print '
    '; + + print $form->buttonsSaveCancel(); //print '
    '; } @@ -605,7 +597,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if (!$i) { $totalarray['nbfield']++; } - if (!empty($val['isameasure'])) { + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; } @@ -640,7 +632,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($sortorder) { $url .= '&page='.urlencode($sortorder); } - print ''.img_edit().''; + print ''.img_edit().''; //print '   '; print ''.img_delete().'   '; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index dbb670039d2..b896c8962b4 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -160,6 +160,7 @@ if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabhelp = array(); $tabhelp[25] = array( + 'label'=>$langs->trans('EnterAnyCode'), 'topic'=>''.$helpsubstit.'', 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>''.$helpsubstit.'', @@ -683,8 +684,8 @@ if ($action == 'view') { $tmpaction = 'create'; $parameters = array( - 'fieldlist' => $fieldlist, - 'tabname' => $tabname[$id] + 'fieldlist' => $fieldlist, + 'tabname' => $tabname[$id] ); $reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; @@ -746,7 +747,7 @@ if ($action == 'view') { if ($tmpfieldlist == 'topic') { print ''; if ($action != 'edit') { - print ''; + print ''; } print ''; } @@ -822,7 +823,7 @@ if ($resql) { print ''; } elseif ($value == 'fk_user') { print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth150'); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150'); print ''; } elseif ($value == 'topic') { print ''; @@ -935,7 +936,7 @@ if ($resql) { print ''; print ''; print ''; - print ''; + print ''; print '
    '; print ''; print ''; @@ -1166,7 +1167,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($value == 'fk_user') { print ''; if ($user->admin) { - print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth200'); + print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth300'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 939273c1da2..a94bb9c4276 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -232,7 +232,7 @@ if ($action == 'edit') { print dol_get_fiche_head($head, 'common_ticket', '', -1); print ''.$langs->trans("EMailsDesc")."
    \n"; - print "
    \n"; + print "

    \n"; clearstatcache(); @@ -380,18 +380,14 @@ if ($action == 'edit') { print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; } else { print dol_get_fiche_head($head, 'common_ticket', '', -1); print ''.$langs->trans("EMailsDesc")."
    \n"; - print "
    \n"; + print "

    \n"; print ''; print ''; @@ -483,7 +479,7 @@ if ($action == 'edit') { print '
    '; - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') { if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike) { diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 2e84efbfb06..65906b83f3c 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -281,7 +281,7 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup'); - print '
    '; + print ''; print ''; print dol_get_fiche_head(); @@ -391,11 +391,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; } elseif ($action == 'edit') { @@ -516,12 +512,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - // Bouton - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 53cbc1aad69..9c2b91ec586 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -133,7 +133,7 @@ if ($action == 'install') { // $original_file should match format module_modulename-x.y[.z].zip $original_file = basename($_FILES["fileinstall"]["name"]); - $original_file = preg_replace('/\(\d+\)\.zip$/i', '.zip', $original_file); + $original_file = preg_replace('/\s*\(\d+\)\.zip$/i', '.zip', $original_file); $newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file; if (!$original_file) { @@ -801,16 +801,16 @@ if ($mode == 'common' || $mode == 'commonkanban') { if (!empty($objMod->config_page_url) && !$disableSetup) { $backtourlparam = ''; if ($search_keyword != '') { - $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.$search_keyword; // No urlencode here, done later + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.urlencode($search_keyword); // No urlencode here, done later } if ($search_nature > -1) { - $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.$search_nature; // No urlencode here, done later + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.urlencode($search_nature); // No urlencode here, done later } if ($search_version > -1) { - $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.$search_version; // No urlencode here, done later + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.urlencode($search_version); // No urlencode here, done later } if ($search_status > -1) { - $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.$search_status; // No urlencode here, done later + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.urlencode($search_status); // No urlencode here, done later } $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; @@ -878,7 +878,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } $codeenabledisable .= ''."\n"; - $codeenabledisable .= 'initAsSpecimen(); + $mo->initAsSpecimen(); // Search template files $file = ''; $classname = ''; $filefound = 0; @@ -88,7 +88,7 @@ if ($action == 'updateMask') { $module = new $classname($db); - if ($module->write_file($mrp, $langs) > 0) { + if ($module->write_file($mo, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf"); return; } else { @@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
    '.$langs->trans($tmp).'
    '; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } @@ -235,7 +235,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->MRP_MO_ADDON == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print '
    '; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -359,13 +359,13 @@ foreach ($dirmodels as $reldir) { // Active if (in_array($name, $def)) { print '
    '; } else { print '"; } @@ -374,7 +374,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->MRP_MO_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; @@ -451,7 +451,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print $doleditor->Create(); } print '\n"; print ''; @@ -465,7 +465,7 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftMOs"), $htmltext, 1, ' print '\n"; print ''; diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 373ab0e0f48..e8619219471 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -138,7 +138,7 @@ if ($action == 'add_currency') { $TCurrency = array(); -$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; +$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE entity = ".((int) $conf->entity); $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { @@ -221,7 +221,7 @@ print ''; print ''; print ''; print $form->selectyesno("MULTICURRENCY_BUY_PRICE_IN_CURRENCY",$conf->global->MULTICURRENCY_BUY_PRICE_IN_CURRENCY,1); -print ''; +print ''; print ''; print ''; */ @@ -235,7 +235,7 @@ print ''; print ''; print ''; print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'), $conf->global->MULTICURRENCY_MODIFY_RATE_APPLICATION); -print ''; +print ''; print ''; print ''; @@ -305,7 +305,7 @@ print ''; print ''; print ''; print ''; @@ -330,7 +330,7 @@ foreach ($TCurrency as &$currency) { print ''; print '1 '.$conf->currency.' = '; print ' '.$currency->code.' '; - print ' '; + print ' '; print ''; print ''; print ''; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 4c1df0fa938..8137c34e1e6 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -201,7 +201,7 @@ print ''; print ''; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; -print ''; +print ''; print "
    '; print ''; print ''; -print ''; +print ''; print "
    '.$form->selectCurrency('', 'code', 1).''; print ' '; -print ''; +print ''; print '
    '; -print '
    '; +print $form->buttonsSaveCancel("Save", ''); print ''; @@ -280,7 +280,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { } print '
    '; - print '
    '; + print $form->buttonsSaveCancel("Save", ''); } else { print ''; print ''; @@ -463,7 +463,7 @@ print '
    '; print '
    '; -print '
    '; +print $form->buttonsSaveCancel("Save", ''); print ''; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index e2f123f627c..9bf5be2c294 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -150,7 +150,7 @@ print '
    '; print dol_get_fiche_end(); -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 998b6c39c0f..8697b400a2b 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -334,7 +334,7 @@ if ($mode == 'setup' && $user->admin) { if (!empty($driver)) { if ($submit_enabled) { - print '
    '; + print $form->buttonsSaveCancel("Modify", ''); } } diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index 2e262a1bb7e..fb7dddc092c 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -81,7 +81,7 @@ $head = company_admin_prepare_head(); print dol_get_fiche_head($head, 'openinghours', $langs->trans("Company"), -1, 'company'); print ''.$langs->trans("OpeningHoursDesc")."
    \n"; -print "
    \n"; +print "

    \n"; if (empty($action) || $action == 'edit' || $action == 'updateedit') { /** @@ -92,7 +92,7 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') { print ''; print ''; - print ''."\n"; + print ''."\n"; print '
    '.$langs->trans("Day").''.$langs->trans("Value").'
    '.$langs->trans("Day").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc")); @@ -131,10 +131,7 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') { print '
    '; - print '
    '; - print ''; - print '
    '; - print '
    '; + print $form->buttonsSaveCancel("Save", ''); print ''; } diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 9b380b676b4..089ddbafd23 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -178,7 +178,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
    '.$langs->trans($tmp).'
    '; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } @@ -273,11 +273,7 @@ print ''; print dol_get_fiche_end(); -print '
    '; -print '
    '; -print ''; -print '
    '; -print '
    '; +print $form->buttonsSaveCancel("Modify", ''); print ''; diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 43ad8c15929..997c71bb335 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/admin/credtitransfer.php + * \file htdocs/admin/paymentbybanktransfer.php * \ingroup paymentbybanktransfer * \brief Page to setup payments by credit transfer */ @@ -114,7 +114,7 @@ if ($action == "set") { if ($action == "addnotif") { $bon = new BonPrelevement($db); - $bon->AddNotification($db, GETPOST('user', 'int'), $action); + $bon->addNotification($db, GETPOST('user', 'int'), $action); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -122,7 +122,7 @@ if ($action == "addnotif") { if ($action == "deletenotif") { $bon = new BonPrelevement($db); - $bon->DeleteNotificationById(GETPOST('notif', 'int')); + $bon->deleteNotificationById(GETPOST('notif', 'int')); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -144,7 +144,7 @@ $linkback = ''; -print '
    '; +print ''; print ''; print ''; @@ -200,9 +200,8 @@ if (!$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS) { print ''; print ''; print '
    '; -print '
    '; -print '
    '; +print $form->buttonsSaveCancel("Save", ''); print '
    '; @@ -299,7 +298,7 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print ''."\n"; - print '
    '; + print ''; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print ''; @@ -307,7 +306,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -319,7 +318,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; @@ -430,7 +429,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) } - print '
    '; + print ''; print ''; print ''; print ''; @@ -447,7 +446,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) print $form->selectarray('action',$actions);// select_dolusers(0,'user',0); print ''; - print ''; + print ''; // List of current notifications for objet_type='withdraw' $sql = "SELECT u.lastname, u.firstname,"; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 6cf035f26a4..073a88f2cd0 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2012-2107 Juanjo Menent * Copyright (C) 2019 Ferran Marcet + * Copyright (C) 2021 Anthony Berton * * 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 @@ -52,23 +53,60 @@ if ($cancel) { } if ($action == 'update') { - if (GETPOSTISSET('MAIN_PDF_FORMAT')) dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_PDF_FORMAT')) { + dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity); + } - if (GETPOSTISSET('MAIN_PDF_MARGIN_LEFT')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PDF_MARGIN_RIGHT')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_RIGHT"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PDF_MARGIN_TOP')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PDF_MARGIN_BOTTOM')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_PDF_MARGIN_LEFT')) { + dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_MARGIN_RIGHT')) { + dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_RIGHT"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_MARGIN_TOP')) { + dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_MARGIN_BOTTOM')) { + dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity); + } - if (GETPOSTISSET('MAIN_PROFID1_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PROFID2_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PROFID3_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PROFID4_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PROFID5_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PROFID6_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_PROFID1_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PROFID2_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PROFID3_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PROFID4_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PROFID5_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PROFID6_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } - if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_PDF_NO_SENDER_FRAME')) { + dolibarr_set_const($db, "MAIN_PDF_NO_SENDER_FRAME", GETPOST("MAIN_PDF_NO_SENDER_FRAME"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_NO_RECIPENT_FRAME')) { + dolibarr_set_const($db, "MAIN_PDF_NO_RECIPENT_FRAME", GETPOST("MAIN_PDF_NO_RECIPENT_FRAME"), 'chaine', 0, '', $conf->entity); + } - if (GETPOSTISSET('MAIN_TVAINTRA_NOT_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_PDF_HIDE_SENDER_NAME')) { + dolibarr_set_const($db, "MAIN_PDF_HIDE_SENDER_NAME", GETPOST("MAIN_PDF_HIDE_SENDER_NAME"), 'chaine', 0, '', $conf->entity); + } + + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity); + } + + if (GETPOSTISSET('MAIN_TVAINTRA_NOT_IN_ADDRESS')) { + dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + } if (!empty($conf->projet->enabled)) { if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') { @@ -83,20 +121,54 @@ if ($action == 'update') { } } - if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DESC')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DESC')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), '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); - if (GETPOSTISSET('MAIN_INVERT_SENDER_RECIPIENT')) dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PDF_USE_ISO_LOCATION')) dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), '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); + } + if (GETPOSTISSET('MAIN_INVERT_SENDER_RECIPIENT')) { + dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_USE_ISO_LOCATION')) { + dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_NO_CUSTOMER_CODE')) { + dolibarr_set_const($db, "MAIN_PDF_NO_CUSTOMER_CODE", GETPOST("MAIN_PDF_NO_CUSTOMER_CODE"), 'chaine', 0, '', $conf->entity); + } - if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity); + } - if (GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE')) dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); - if (GETPOSTISSET('SHOW_SUBPRODUCT_REF_IN_PDF')) dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) { + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) { + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity); + } + + if (GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE')) { + dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('SHOW_SUBPRODUCT_REF_IN_PDF')) { + dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity); + } + + if (GETPOSTISSET('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) { + dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity); + } + + if (GETPOSTISSET('PDF_USE_A')) { + dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); + } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -240,7 +312,7 @@ for ($i = 1; $i <= 6; $i++) { $pid = false; } } else { - $pid = img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + $pid = img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } if ($pid) { print ''; + +print ''; + +//Invert sender and recipient + +print ''; + +// Place customer adress to the ISO location + +print ''; + print '
    '.$langs->trans("ShowProfIdInAddress").' - '.$pid.''; @@ -254,6 +326,55 @@ for ($i = 1; $i <= 6; $i++) { } } +// Borders on address frame + +print '
    '.$langs->trans("MAIN_PDF_NO_SENDER_FRAME").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_NO_SENDER_FRAME'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_NO_SENDER_FRAME", $arrval, $conf->global->MAIN_PDF_NO_SENDER_FRAME); +} +print '
    '.$langs->trans("MAIN_PDF_NO_RECIPENT_FRAME").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_NO_RECIPENT_FRAME'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_NO_RECIPENT_FRAME", $arrval, $conf->global->MAIN_PDF_NO_RECIPENT_FRAME); +} + +// Show sender name + +print '
    '.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME'); +} else { + print $form->selectyesno('MAIN_PDF_HIDE_SENDER_NAME', (!empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) ? $conf->global->MAIN_PDF_HIDE_SENDER_NAME : 0, 1); +} +print '
    '.$langs->trans("SwapSenderAndRecipientOnPDF").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_INVERT_SENDER_RECIPIENT'); +} else { + print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); +} +print '
    '.$langs->trans("PlaceCustomerAddressToIsoLocation").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_USE_ISO_LOCATION'); +} else { + print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); +} +print '
    '; print ''; @@ -324,14 +445,24 @@ print '
    '; print ''; print ''; -// Height of logo +// Use 2 languages into PDF +print ''; + +// Height of logo print ''; // Show project - if (!empty($conf->projet->enabled)) { print ''; } -//Invert sender and recipient +// -print ''; -// Place customer adress to the ISO location - -print ''; - -// Use 2 languages into PDF - -print ''; - // Ref print 'selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)); print ''; +// Show online payment link on invoices + +print ''; + +print ''; + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").''; +//if (! empty($conf->global->MAIN_MULTILANGS)) + //{ +$selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0); +print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1); +//} else { +// print ''.$langs->trans("MultiLangNotEnabled").''; +//} +print '
    '.$langs->trans("MAIN_DOCUMENTS_LOGO_HEIGHT").''; print ''; print '
    '.$langs->trans("PDF_SHOW_PROJECT").''; $tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel'); @@ -340,38 +471,18 @@ if (!empty($conf->projet->enabled)) { print '
    '.$langs->trans("SwapSenderAndRecipientOnPDF").''; +print '
    '.$langs->trans("MAIN_PDF_HIDE_CUSTOMER_CODE"); +print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_INVERT_SENDER_RECIPIENT'); + print ajax_constantonoff('MAIN_PDF_HIDE_CUSTOMER_CODE'); } else { - print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_HIDE_CUSTOMER_CODE", $arrval, $conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE); } print '
    '.$langs->trans("PlaceCustomerAddressToIsoLocation").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_PDF_USE_ISO_LOCATION'); -} else { - print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); -} -print '
    '.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").''; -//if (! empty($conf->global->MAIN_MULTILANGS)) -//{ -$selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0); -print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1); -//} else { -// print ''.$langs->trans("MultiLangNotEnabled").''; -//} -print '
    '.$langs->trans("HideRefOnPDF").''; @@ -418,12 +529,28 @@ print '
    '.$langs->trans("ShowDetailsInPDFPageFoot").'
    '.$langs->trans("PDF_SHOW_LINK_TO_ONLINE_PAYMENT").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_SHOW_LINK_TO_ONLINE_PAYMENT'); +} else { + print $form->selectyesno('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) ? $conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT : 0, 1); +} +print '
    '.$langs->trans("PDF_USE_A").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_USE_A'); +} else { + print $form->selectyesno('PDF_USE_A', (empty($conf->global->PDF_USE_A) ? 0 : $conf->global->PDF_USE_A), 1); +} +print '
    '; print '
    '; -print '
    '; -print ''; -print '
    '; +print $form->buttonsSaveCancel("Save", ''); print '
    '; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index f03bfc6a5ec..f42c49a4bfe 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -41,19 +41,25 @@ if (!$user->admin) { } $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'alpha'); /* * Actions */ -if ($cancel) { - $action = ''; -} - if ($action == 'update') { - if (GETPOSTISSET('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) dolibarr_set_const($db, "MAIN_GENERATE_PROPOSALS_WITH_PICTURE", GETPOST("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('PROPOSAL_PDF_HIDE_PAYMENTTERM')) { + dolibarr_set_const($db, "PROPOSAL_PDF_HIDE_PAYMENTTERM", GETPOST("PROPOSAL_PDF_HIDE_PAYMENTTERM"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('PROPOSAL_PDF_HIDE_PAYMENTMODE')) { + dolibarr_set_const($db, "PROPOSAL_PDF_HIDE_PAYMENTMODE", GETPOST("PROPOSAL_PDF_HIDE_PAYMENTMODE"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) { + dolibarr_set_const($db, "MAIN_GENERATE_PROPOSALS_WITH_PICTURE", GETPOST("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')) { + dolibarr_set_const($db, "MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", GETPOST("MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", 'int'), 'chaine', 0, '', $conf->entity); + } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -84,46 +90,46 @@ $tooltiptext = ''; print ''.$form->textwithpicto($langs->trans("PDFOtherDesc"), $tooltiptext)."
    \n"; print "
    \n"; -print load_fiche_titre($langs->trans("Proposal"), '', ''); +if (!empty($conf->propal->enabled)) { + print load_fiche_titre($langs->trans("Proposal"), '', ''); -print '
    '; -print ''; -print ''; + print ''; + print ''; + print ''; -print '
    '; -print ''; -print ''; + print '
    '; + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; + print ''; -print ''; + + /* + print ''; + */ + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"); -print ' ('.$langs->trans("RandomlySelectedIfSeveral").')'; -print ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_GENERATE_PROPOSALS_WITH_PICTURE'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MAIN_GENERATE_PROPOSALS_WITH_PICTURE", $arrval, $conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE); + print '
    '.$langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"); + print ' ('.$langs->trans("RandomlySelectedIfSeveral").')'; + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_PROPOSALS_WITH_PICTURE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_GENERATE_PROPOSALS_WITH_PICTURE", $arrval, $conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE); + } + print '
    '.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING", $arrval, $conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING); + } + print '
    '; + print '
    '; } -print ''; -/* -print ''.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING", $arrval, $conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING); -} -print ''; -*/ - -print ''; -print ''; - -/* print '
    '; print ''; print '
    '; -*/ print '
    '; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 8f4c0c6f763..d2f0d79e4f3 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -236,7 +236,7 @@ if ($result) { print ''; } else { print ''; - print ''; + print ''; //print img_edit_add(); print img_picto('', 'switch_off'); print ''; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 01e3b6d4913..e09dd13b045 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -117,7 +117,7 @@ if ($action == "set") { if ($action == "addnotif") { $bon = new BonPrelevement($db); - $bon->AddNotification($db, GETPOST('user', 'int'), $action); + $bon->addNotification($db, GETPOST('user', 'int'), $action); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -125,7 +125,7 @@ if ($action == "addnotif") { if ($action == "deletenotif") { $bon = new BonPrelevement($db); - $bon->DeleteNotificationById(GETPOST('notif', 'int')); + $bon->deleteNotificationById(GETPOST('notif', 'int')); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -214,9 +214,8 @@ print ''; +print $form->buttonsSaveCancel("Save", ''); print ''; @@ -313,7 +312,7 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print ''."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print ''; @@ -321,7 +320,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -333,7 +332,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; @@ -444,7 +443,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) } - print '
    '; + print ''; print ''; print ''; print ''; @@ -461,7 +460,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) print $form->selectarray('action',$actions);// select_dolusers(0,'user',0); print ''; - print ''; + print ''; // List of current notifications for objet_type='withdraw' $sql = "SELECT u.lastname, u.firstname,"; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index a0d590579ca..22ce045a7ab 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -268,7 +268,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
    '.$langs->trans($tmp).'
    '; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } @@ -278,7 +278,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->PROPALE_ADDON == "$file") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -402,13 +402,13 @@ foreach ($dirmodels as $reldir) { // Active if (in_array($name, $def)) { print ''; } else { print ""; } @@ -417,7 +417,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->PROPALE_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; @@ -483,7 +483,7 @@ print ''; print $langs->trans("PaymentMode").''; print ''; print "\n"; @@ -587,7 +587,7 @@ print ""; print ''; print ''; print '"; -print ''; +print ''; print ''; print ''; @@ -600,7 +600,7 @@ print $langs->trans("UseCustomerContactAsPropalRecipientIfExist"); print '\n"; print ''; */ @@ -627,7 +627,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print $doleditor->Create(); } print '\n"; print ''; @@ -640,7 +640,7 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext, print '\n"; print ''; @@ -658,11 +658,11 @@ if ($conf->banque->enabled) { if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL)) { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } else { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } } print ''; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index af646bb4096..451771f7a98 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -95,6 +95,7 @@ $head = security_prepare_head(); print dol_get_fiche_head($head, 'proxy', '', -1); +print '
    '; if ($conf->use_javascript_ajax) { print "\n".' + '; print "\n"; + ?> + + + + id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Modify if ($object->status == $object::STATUS_DRAFT) { if ($permissiontoadd) { - print ''.$langs->trans("Modify").''."\n"; + print ''.$langs->trans("Modify").''."\n"; } else { print ''.$langs->trans('Modify').''."\n"; } @@ -623,24 +694,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Re-open if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) { - print ''.$langs->trans("ReOpen").''."\n"; + print ''.$langs->trans("ReOpen").''."\n"; } // Create MO if ($conf->mrp->enabled) { if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) { - print ''.$langs->trans("CreateMO").''."\n"; + print ''.$langs->trans("CreateMO").''."\n"; } } // Clone if ($permissiontoadd) { - print ''.$langs->trans("ToClone").''."\n"; + print ''.$langs->trans("ToClone").''."\n"; } // Close / Cancel if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) { - print ''.$langs->trans("Disable").''."\n"; + print ''.$langs->trans("Disable").''."\n"; } /* @@ -658,7 +729,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ if ($permissiontodelete) { - print ''.$langs->trans('Delete').''."\n"; + print ''.$langs->trans('Delete').''."\n"; } else { print ''.$langs->trans('Delete').''."\n"; } @@ -690,20 +761,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; $MAXEVENT = 10; - $morehtmlright = ''; + $morehtmlright = ''; $morehtmlright .= $langs->trans("SeeAll"); $morehtmlright .= ''; // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + $somethingshown = $formactions->showactions($object, $object->element, $socid, 1, '', $MAXEVENT, '', $morehtmlright); - print '
    '; + print ''; } //Select mail models is same action as presend diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index dd0227e4305..c36ac32bb59 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -125,7 +125,7 @@ if ($object->id) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index df21938aec5..3cc0dc1753a 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -297,7 +297,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.' ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key.' ' : ''); } } // Add fields from hooks @@ -363,7 +363,7 @@ $sql .= $hookmanager->resPrint; $sql.= " GROUP BY "; foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= "t.".$key.", "; } // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { @@ -655,7 +655,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if (!$i) { $totalarray['nbfield']++; } - if (!empty($val['isameasure'])) { + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; } diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 539eb654751..8ace40cc900 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -70,7 +70,13 @@ restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once +$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 +} /* @@ -94,7 +100,7 @@ if ($id > 0 || !empty($ref)) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 91eb752451b..fd8d4a19a75 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -94,7 +94,7 @@ class BOM extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'2', 'autofocusoncreate'=>1, 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200'), @@ -431,7 +431,7 @@ class BOM extends CommonObject if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.rowid') { - $sqlwhere[] = $key.' = '.((int) $value); + $sqlwhere[] = $key." = ".((int) $value); } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; } elseif ($key == 'customsql') { @@ -442,14 +442,14 @@ class BOM extends CommonObject } } if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); + $sql .= $this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -1139,6 +1139,7 @@ class BOMLine extends CommonObjectLine 'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1,), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'fk_bom_child' => array('type'=>'integer:BOM:bom/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'notnull'=>-1,), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), @@ -1163,6 +1164,11 @@ class BOMLine extends CommonObjectLine */ public $fk_product; + /** + * @var int Id of parent bom + */ + public $fk_bom_child; + /** * @var string description */ @@ -1295,25 +1301,25 @@ class BOMLine extends CommonObjectLine if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; + $sqlwhere[] = $key." = ".((int) $value); } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; } elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); + $sql .= $this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -1390,7 +1396,7 @@ class BOMLine extends CommonObjectLine $label .= '
    '; $label .= ''.$langs->trans('Ref').': '.$this->ref; - $url = dol_buildpath('/bom/bomline_card.php', 1).'?id='.$this->id; + $url = DOL_URL_ROOT.'/bom/bomline_card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 8f3cadeedc2..edd9bd69ef4 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -54,7 +54,9 @@ function bomAdminPrepareHead() //$this->tabs = array( // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__' //); // to remove a tab - complete_head_from_modules($conf, $langs, null, $head, $h, 'bom'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'bom@mrp'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom@mrp', 'remove'); return $head; } diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index fcba37105d3..c42da9bdb19 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -24,7 +24,7 @@ if (empty($conf) || !is_object($conf)) { exit; } -print "\n"; +print "\n"; global $user, $db; global $noMoreLinkedObjectBlockAfter; @@ -73,7 +73,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo '
    '; echo "\n"; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 7cc2873b261..d96f8da2791 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -61,6 +61,8 @@ if ($nolinesbefore) { print ''; + // Linked BOM + print ''; print ''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; $coldisplay++; print ''; $coldisplay += $colspan; print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 46b57e89243..54e145ad2ee 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -97,6 +97,8 @@ print ''; */ $coldisplay++; +// For BOM +print ''; print '\n"; print ''; +print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; +print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { @@ -52,6 +54,9 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { // Description print ''; +// Linked BOM +print ''; + // Qty print ''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index fff9d077a08..8256019bd98 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -80,9 +80,22 @@ print '
    '; $coldisplay++; $tmpproduct = new Product($object->db); $tmpproduct->fetch($line->fk_product); +$tmpbom = new BOM($object->db); +$res = $tmpbom->fetch($line->fk_bom_child); +if (!empty($tmpbom->id)) { + print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; +} print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; print ''; + +// To show BOM links in the list +if ($res > 0) { + print ''; +} else { + print ''; +} + print ''; -print ''; @@ -121,7 +135,7 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { } else { - print 'id.'">'.img_edit().''; + print 'id.'">'.img_edit().''; } print ''; @@ -129,7 +143,7 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { $coldisplay++; if (($line->fk_prev_id == null) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation - print 'id.'">'; + print 'id.'">'; print img_delete(); print ''; } @@ -166,6 +180,93 @@ if ($action == 'selectlines') { print ''; +// Select of all the sub-BOM lines +$sql = 'SELECT rowid, fk_bom_child, fk_product FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; +$sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; +$resql = $object->db->query($sql); + +if ($resql) { + // Loop on all the sub-BOM lines if they exist + while ($obj = $object->db->fetch_object($resql)) { + $sub_bom_product = new Product($object->db); + $sub_bom_product->fetch($obj->fk_product); + + $sub_bom = new BOM($object->db); + $sub_bom->fetch($obj->fk_bom_child); + + $sub_bom_line = new BOMLine($object->db); + $sub_bom_line->fetch($obj->rowid); + + //If hidden conf is set, we show directly all the sub-BOM lines + if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) { + print ''; + } else { + print ''; + } + + // Product + print ''; + + // Sub-BOM + if ($sub_bom_line->fk_bom_child > 0) { + print ''; + } else { + print ''; + } + + // Qty + print ''; + if ($sub_bom_line->qty_frozen > 0) { + print ''; + } else { + print ''; + } + + // Disable stock change + if ($sub_bom_line->disable_stock_change > 0) { + print ''; + } else { + print ''; + } + + // Efficiency + print ''; + + // Cost price if it's defined + if ($sub_bom_product->cost_price > 0) { + print ''; + $total_cost.= $sub_bom_product->cost_price * $line->qty; + } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined + print ''; + $total_cost.= $sub_bom_product->pmp * $line->qty; + } else { // Minimum purchase price if cost price and PMP aren't defined + $sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql_supplier_price.= ' WHERE fk_product = '. (int) $sub_bom_product->id; + $resql_supplier_price = $object->db->query($sql_supplier_price); + if ($resql_supplier_price) { + $obj = $object->db->fetch_object($resql_supplier_price); + print ''; + $total_cost+= $obj->min_price * $line->qty; + } + } + + print ''; + print ''; + print ''; + } +} + +// Replace of the total_cost value by the sum of all sub-BOM lines total_cost +if ($total_cost > 0) { + $line->total_cost = price($total_cost); + ?> + + showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1, 'line'); diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index 5f30db5d7f2..3d5c8eb3bc0 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -78,7 +78,7 @@ print ''; -print '
    '."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; if (empty($conf->facture->enabled)) { - print ''; + print ''; } print '
    '.$langs->trans("DefaultProposalDurationValidity").''."global->PROPALE_VALIDITY_DURATION."\">
    '; print $form->selectyesno("value",$conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1); print ''; -print ''; +print ''; print "
    '; -print ''; +print ''; print "
    '; print ''; print ''; -print ''; +print ''; print "
    '; // For now, shipments must stay linked to order, so link is not deletable if ($object->element != 'shipping') { - echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; } echo '
    '; print '
    '.$langs->trans('AddNewLine').''; print '
    '.$langs->trans('BOM').''.$langs->trans('Qty').''; @@ -107,6 +109,10 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { echo ''; } +$coldisplay++; +print ''; +print ''; +print ''; @@ -138,7 +144,7 @@ print ''; -print ''; +print ''; print '
    '; if (($line->info_bits & 2) != 2) { diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index d1b29ee03b0..0656f23aed9 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -43,6 +43,8 @@ print "\n"; print "
    '.$langs->trans('Description').''.$langs->trans('BOM').''.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).''.$tmpbom->getNomUrl(1).' '; $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price @@ -111,7 +124,8 @@ $coldisplay++; echo $line->efficiency; print ''; +$total_cost = 0; +print ''; $coldisplay++; echo price($line->total_cost); print '
    '.$sub_bom_product->getNomUrl(1).''.$sub_bom->getNomUrl(1).' '.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''.$sub_bom_line->qty_frozen.' '.$sub_bom_line->disable_stock_change.' '.$sub_bom_line->efficiency.''.price($sub_bom_product->cost_price * $line->qty).''.price($sub_bom_product->pmp * $line->qty).''.price($obj->min_price * $line->qty).'
    '; print $langs->trans("NbOfBoomarkToShow").''; print ''; print '

    '; +print '
    '; // End of page llxFooter(); diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 1094eabf0c6..289916a07c2 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; $langs->loadLangs(array('bookmarks', 'other')); // Security check -if (!$user->rights->bookmark->lire) { +if (empty($user->rights->bookmark->lire)) { restrictedArea($user, 'bookmarks'); } @@ -40,7 +40,7 @@ $action = GETPOST("action", "alpha"); $title = (string) GETPOST("title", "alpha"); $url = (string) GETPOST("url", "alpha"); $urlsource = GETPOST("urlsource", "alpha"); -$target = GETPOST("target", "alpha"); +$target = GETPOST("target", "int"); $userid = GETPOST("userid", "int"); $position = GETPOST("position", "int"); $backtopage = GETPOST('backtopage', 'alpha'); @@ -154,9 +154,9 @@ if ($action == 'create') { print ''; print ''; - print load_fiche_titre($langs->trans("NewBookmark")); + print load_fiche_titre($langs->trans("NewBookmark"), '', 'bookmark'); - print dol_get_fiche_head($head, $hselected, $langs->trans("Bookmark"), -1, 'bookmark'); + print dol_get_fiche_head(null, 'bookmark', '', 0, ''); print ''; @@ -164,32 +164,29 @@ if ($action == 'create') { dol_set_focus('#titlebookmark'); // Url - print ''; + print ''; // Target print ''; // Owner print ''; + print img_picto('', 'user').' '.$form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id, 'userid', 0, '', 0, ($user->admin ? '' : array($user->id)), '', 0, 0, 0, '', ($user->admin) ? 1 : 0, '', 'maxwidth300 widthcentpercentminusx'); + print ''; // Position print ''; + print 'position).'">'; + print ''; print '
    '.$langs->trans("UrlOrLink").''.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'
    '.$langs->trans("UrlOrLink").''.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'
    '.$langs->trans("BehaviourOnClick").''; $liste = array(0=>$langs->trans("ReplaceWindow"), 1=>$langs->trans("OpenANewWindow")); - print $form->selectarray('target', $liste, 1); + print $form->selectarray('target', $liste, GETPOSTISSET('target') ? GETPOST('target', 'int') : 1, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); print ''.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'
    '.$langs->trans("Visibility").''; - print img_picto('', 'user').' '.$form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id, 'userid', 0, '', 0, ($user->admin ? '' : array($user->id)), '', 0, 0, 0, '', ($user->admin) ? 1 : 0, '', 'maxwidth300'); - print ' 
    '.$langs->trans("Position").''; - print 'position).'">'; - print ' 
    '; print dol_get_fiche_end(); - print '
    '; - print '   '; - print ''; - print '
    '; + print $form->buttonsSaveCancel("CreateBookmark"); print ''; } @@ -301,7 +298,8 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { print dol_get_fiche_end(); if ($action == 'edit') { - print '
       
    '; + print $form->buttonsSaveCancel(); + print ''; } @@ -312,12 +310,12 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { // Edit if ($user->rights->bookmark->creer && $action != 'edit') { - print ''.$langs->trans("Edit").''."\n"; + print ''.$langs->trans("Edit").''."\n"; } // Remove if ($user->rights->bookmark->supprimer && $action != 'edit') { - print ''.$langs->trans("Delete").''."\n"; + print ''.$langs->trans("Delete").''."\n"; } print ''; diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 17be6be9cef..8a5de8f4d91 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -35,7 +35,7 @@ $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bookmarklist'; // To manage different context of search // Security check -if (!$user->rights->bookmark->lire) { +if (empty($user->rights->bookmark->lire)) { restrictedArea($user, 'bookmarks'); } $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php deleted file mode 100644 index eee5cac755f..00000000000 --- a/htdocs/cashdesk/admin/cashdesk.php +++ /dev/null @@ -1,191 +0,0 @@ - - * Copyright (C) 2011-2017 Juanjo Menent - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/admin/cashdesk.php - * \ingroup cashdesk - * \brief Setup page for cashdesk module - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - -// If socid provided by ajax company selector -if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { - $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); - $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); - $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); -} - -// Security check -if (!$user->admin) { - accessforbidden(); -} - -// Load translation files required by the page -$langs->loadLangs(array("admin", "cashdesk")); - - -/* - * Actions - */ - -if (GETPOST('action', 'alpha') == 'set') { - $db->begin(); - - if (GETPOST('socid', 'int') < 0) { - $_POST["socid"] = ''; - } - - $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE", (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB", (GETPOST('CASHDESK_ID_BANKACCOUNT_CB', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB', 'alpha') : ''), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE", (GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", GETPOST('CASHDESK_NO_DECREASE_STOCK', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_DOLIBAR_RECEIPT_PRINTER", GETPOST('CASHDESK_DOLIBAR_RECEIPT_PRINTER', 'alpha'), 'chaine', 0, '', $conf->entity); - - dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); - - if (!($res > 0)) { - $error++; - } - - if (!$error) { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - -/* - * View - */ - -$form = new Form($db); -$formproduct = new FormProduct($db); - -llxHeader('', $langs->trans("CashDeskSetup")); - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)', $linkback, 'title_setup'); -print '
    '; - - -// Mode -print '
    '; -print ''; -print ''; - -if (!empty($conf->service->enabled)) { - print ''; - print ''; - print ''; - print "\n"; - - print '\n"; - - print '
    '.$langs->trans("Parameters").''.$langs->trans("Value").'
    '; - print $langs->trans("CashdeskShowServices"); - print ''; - print $form->selectyesno("CASHDESK_SERVICES", $conf->global->CASHDESK_SERVICES, 1); - print "
    '; - - print '
    '; -} - - -print ''; -print ''; -print ''; -print "\n"; - -print ''; -print ''; -if (!empty($conf->banque->enabled)) { - print ''; - print ''; - - - print ''; - print ''; - - - print ''; - print ''; -} - -if (!empty($conf->stock->enabled)) { - print ''; // Force warehouse (this is not a default value) - print ''; - - $disabled = $conf->global->CASHDESK_NO_DECREASE_STOCK; - - - print ''; // Force warehouse (this is not a default value) - print ''; -} - -// Use Dolibarr Receipt Printer -if (!empty($conf->receiptprinter->enabled)) { - print '\n"; -} - -print '
    '.$langs->trans("Terminal").' 0'.$langs->trans("Value").'
    '.$langs->trans("CashDeskThirdPartyForSell").''; -print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0); -print '
    '.$langs->trans("CashDeskBankAccountForSell").''; - $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1); - print '
    '.$langs->trans("CashDeskBankAccountForCheque").''; - $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE, 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", 1); - print '
    '.$langs->trans("CashDeskBankAccountForCB").''; - $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB, 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", 1); - print '
    '.$langs->trans("CashDeskDoNotDecreaseStock").''; - if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); - } else { - if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); - } - print $langs->trans("Yes").'
    '; - print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; - } - print '
    '.$langs->trans("CashDeskIdWareHouse").''; - if (!$disabled) { - print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled); - print ' ('.$langs->trans("Create").')'; - } else { - print ''.$langs->trans("StockDecreaseForPointOfSaleDisabled").''; - } - print '
    '; - print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; - print ''; - print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); - print "
    '; -print '
    '; - -print '
    '; - -print "
    \n"; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php deleted file mode 100644 index d8e31f3b9c9..00000000000 --- a/htdocs/cashdesk/affContenu.php +++ /dev/null @@ -1,100 +0,0 @@ - - * Copyright (C) 2008-2009 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/affContenu.php - * \ingroup cashdesk - * \brief Include to show main page for cashdesk module - */ - -require_once 'class/Facturation.class.php'; - -// Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles) -if (GETPOST('id', 'int') == 'NOUV') { - unset($_SESSION['serObjFacturation']); - unset($_SESSION['poscart']); -} - -// Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... -if (isset($_SESSION['serObjFacturation'])) { - $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset($_SESSION['serObjFacturation']); -} else { - // ... sinon, c'est une nouvelle vente - $obj_facturation = new Facturation(); -} - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * View - */ - -// $obj_facturation contains data for all invoice total + selection of current product - -$obj_facturation->calculTotaux(); // Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart'] - -$total_ttc = $obj_facturation->amountWithTax(); - -/*var_dump($obj_facturation); -var_dump($_SESSION['poscart']); -var_dump($total_ttc); -exit;*/ - - -// Left area with selected articles (area for article, amount and payments) -print '
    '; -print '
    '; - -$page = GETPOST('menutpl', 'alpha'); -if (empty($page)) { - $page = 'facturation'; -} - -if (in_array( - $page, - array( - 'deconnexion', - 'index', 'index_verif', 'facturation', 'facturation_verif', 'facturation_dhtml', - 'validation', 'validation_ok', 'validation_ticket', 'validation_verif', - ) -)) { - include $page.'.php'; -} else { - dol_print_error('', 'menu param '.$page.' is not inside allowed list'); -} - -print '
    '; -print '
    '; - - - -// Right area with selected articles (shopping cart) -print '
    '; -print '
    '; - -require 'tpl/liste_articles.tpl.php'; - -print '
    '; -print '
    '; - -$_SESSION['serObjFacturation'] = serialize($obj_facturation); diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php deleted file mode 100644 index a352649feb4..00000000000 --- a/htdocs/cashdesk/affIndex.php +++ /dev/null @@ -1,78 +0,0 @@ - - * Copyright (C) 2008-2010 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/affIndex.php - * \ingroup cashdesk - * \brief First page of point of sale module - */ -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/keypad.php'; - -$error = GETPOST('error'); - -// Test if already logged -if ($_SESSION['uid'] <= 0) { - header('Location: index.php'); - exit; -} - -// Load translation files required by the page -$langs->loadLangs(array("companies", "compta", "cashdesk")); - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * View - */ - -$form = new Form($db); - -$arrayofjs = array(); -$arrayofcss = array('/cashdesk/css/style.css'); - -top_htmlhead($head, $langs->trans("CashDesk"), 0, 0, $arrayofjs, $arrayofcss); - -print ''."\n"; - -if (!empty($error)) { - dol_htmloutput_events(); -} - -print '
    '."\n"; -print '
    '."\n"; -print '
    '."\n"; - -print ''."\n"; - -print '
    '."\n"; -include_once 'affContenu.php'; -print '
    '."\n"; - -include_once 'affPied.php'; - -print '
    '."\n"; -print ''."\n"; diff --git a/htdocs/cashdesk/affPied.php b/htdocs/cashdesk/affPied.php deleted file mode 100644 index 6481a0c2aff..00000000000 --- a/htdocs/cashdesk/affPied.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/affPied.php - * \ingroup cashdesk - * \brief Bottom of main page of point of sale module - */ - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - -?> - -
    -use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) { - print "\n\n"; - print '' . "\n"; -} - -printCommonFooter('private'); -?> -
    diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php deleted file mode 100644 index 23fa4d6d0a1..00000000000 --- a/htdocs/cashdesk/class/Auth.class.php +++ /dev/null @@ -1,144 +0,0 @@ - - * Copyright (C) 2008-2011 Laurent Destailleur - * - * 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 . - */ - - -/** - * Class ot manage authentication for pos module (cashdesk) - */ -class Auth -{ - protected $db; - - private $login; - private $passwd; - - private $reponse; - - public $sqlQuery; - - /** - * Enter description here ... - * - * @param DoliDB $db Database handler - * @return void - */ - public function __construct($db) - { - $this->db = $db; - $this->reponse(null); - } - - /** - * Enter description here ... - * - * @param string $aLogin Login - * @return void - */ - public function login($aLogin) - { - $this->login = $aLogin; - } - - /** - * Enter description here ... - * - * @param string $aPasswd Password - * @return void - */ - public function passwd($aPasswd) - { - $this->passwd = $aPasswd; - } - - /** - * Enter description here ... - * - * @param string $aReponse Response - * @return void - */ - public function reponse($aReponse) - { - $this->reponse = $aReponse; - } - - /** - * Validate login/pass - * - * @param string $aLogin Login - * @param string $aPasswd Password - * @return int 0 or 1 - */ - public function verif($aLogin, $aPasswd) - { - global $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_auto_user; - - $ret = -1; - - $login = ''; - - $test = true; - - // Authentication mode - if (empty($dolibarr_main_authentication)) { - $dolibarr_main_authentication = 'http,dolibarr'; - } - // Authentication mode: forceuser - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) { - $dolibarr_auto_user = 'auto'; - } - // Set authmode - $authmode = explode(',', $dolibarr_main_authentication); - - // No authentication mode - if (!count($authmode)) { - $langs->load('main'); - dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); - exit; - } - - $usertotest = $aLogin; - $passwordtotest = $aPasswd; - $entitytotest = $conf->entity; - - // Validation tests user / password - // If ok, the variable will be initialized login - // If error, we will put error message in session under the name dol_loginmesg - $goontestloop = false; - if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) { - $goontestloop = true; - } - if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) { - $goontestloop = true; - } - - if ($test && $goontestloop) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); - if ($login) { - $this->login($aLogin); - $this->passwd($aPasswd); - $ret = 0; - } else { - $ret = -1; - } - } - - return $ret; - } -} diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php deleted file mode 100644 index 339edce5f03..00000000000 --- a/htdocs/cashdesk/class/Facturation.class.php +++ /dev/null @@ -1,558 +0,0 @@ - - * Copyright (C) 2008-2010 Laurent Destailleur - * Copyright (C) 2010 Juanjo Menent - * - * 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 . - */ - -include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - - -/** - * Class to manage invoices for pos module (cashdesk) - */ -class Facturation -{ - /** - * Attributs "volatiles" : reinitialises apres chaque traitement d'un article - *

    Attributs "volatiles" : reinitialises apres chaque traitement d'un article

    - * int $id => 'rowid' du produit dans llx_product - * string $ref => 'ref' du produit dans llx_product - * int $qte => Quantite pour le produit en cours de traitement - * int $stock => Stock theorique pour le produit en cours de traitement - * int $remise_percent => Remise en pourcent sur le produit en cours - * int $montant_remise => Remise en pourcent sur le produit en cours - * int $prix => Prix HT du produit en cours - * int $tva => 'rowid' du taux de tva dans llx_c_tva - */ - - /** - * @var int ID - */ - public $id; - - protected $ref; - protected $qte; - protected $stock; - protected $remise_percent; - protected $montant_remise; - protected $prix; - protected $tva; - - /** - * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) - * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) - * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) - * int $montant_encaisse => Montant encaisse en cas de reglement en especes - * int $montant_rendu => Monnaie rendue en cas de reglement en especes - * int $paiement_le => Date de paiement en cas de paiement differe - * - * int $prix_total_ht => Prix total hors taxes - * int $montant_tva => Montant total de la TVA, tous taux confondus - * int $prix_total_ttc => Prix total TTC - */ - protected $num_facture; - protected $mode_reglement; - protected $montant_encaisse; - protected $montant_rendu; - protected $paiement_le; - - protected $prix_total_ht; - protected $montant_tva; - protected $prix_total_ttc; - - - /** - * Constructor - */ - public function __construct() - { - $this->raz(); - $this->razPers(); - } - - - // Data processing methods - - - /** - * Add a product into cart - * - * @return void - */ - public function ajoutArticle() - { - global $conf, $db, $mysoc; - - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - - $societe = new Societe($db); - $societe->fetch($thirdpartyid); - - $product = new Product($db); - $product->fetch($this->id); - - - $vatrowid = $this->tva(); - - $tmp = getTaxesFromId($vatrowid); - $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); - $vat_npr = $tmp['npr']; - - $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); - - // Clean vat code - $reg = array(); - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } - - // Define part of HT, VAT, TTC - $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); - - // Calculation of total HT without discount - $total_ht = $resultarray[0]; - $total_vat = $resultarray[1]; - $total_ttc = $resultarray[2]; - $total_localtax1 = $resultarray[9]; - $total_localtax2 = $resultarray[10]; - - // Calculation of the discount amount - if ($this->remisePercent()) { - $remise_percent = $this->remisePercent(); - } else { - $remise_percent = 0; - } - $montant_remise_ht = ($resultarray[6] - $resultarray[0]); - $this->amountDiscount($montant_remise_ht); - - $newcartarray = $_SESSION['poscart']; - - $i = 0; - if (!is_null($newcartarray) && !empty($newcartarray)) { - $i = count($newcartarray); - } - - $newcartarray[$i]['id'] = $i; - $newcartarray[$i]['ref'] = $product->ref; - $newcartarray[$i]['label'] = $product->label; - $newcartarray[$i]['price'] = $product->price; - $newcartarray[$i]['price_ttc'] = $product->price_ttc; - - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - if (isset($product->multiprices[$societe->price_level])) { - $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; - $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; - } - } - - $newcartarray[$i]['fk_article'] = $this->id; - $newcartarray[$i]['qte'] = $this->qte(); - $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid - $newcartarray[$i]['remise_percent'] = $remise_percent; - $newcartarray[$i]['remise'] = price2num($montant_remise_ht); - $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); - $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); - $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); - $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); - $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); - $_SESSION['poscart'] = $newcartarray; - - $this->raz(); - } - - /** - * Remove a product from panel - * - * @param int $aArticle Id of line into cart to remove - * @return void - */ - public function supprArticle($aArticle) - { - $poscart = $_SESSION['poscart']; - - $j = 0; - $newposcart = array(); - foreach ($poscart as $key => $val) { - if ($poscart[$key]['id'] != $aArticle) { - $newposcart[$j] = $poscart[$key]; - $newposcart[$j]['id'] = $j; - $j++; - } - } - unset($poscart); - //var_dump($poscart);exit; - $_SESSION['poscart'] = $newposcart; - } - - /** - * Calculation of total HT, total TTC and VAT amounts - * - * @return int Total - */ - public function calculTotaux() - { - global $db; - - $total_ht = 0; - $total_ttc = 0; - $total_vat = 0; - $total_localtax1 = 0; - $total_localtax2 = 0; - - $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); - - $tab_size = count($tab); - for ($i = 0; $i < $tab_size; $i++) { - // Total HT - $remise = $tab[$i]['remise']; - $total_ht += ($tab[$i]['total_ht']); - $total_vat += ($tab[$i]['total_vat']); - $total_ttc += ($tab[$i]['total_ttc']); - $total_localtax1 += ($tab[$i]['total_localtax1']); - $total_localtax2 += ($tab[$i]['total_localtax2']); - } - - $this->prix_total_ttc = $total_ttc; - $this->prix_total_ht = $total_ht; - $this->prix_total_vat = $total_vat; - $this->prix_total_localtax1 = $total_localtax1; - $this->prix_total_localtax2 = $total_localtax2; - - $this->montant_tva = $total_ttc - $total_ht; - //print 'total: '.$this->prix_total_ttc; exit; - } - - /** - * Reset attributes - * - * @return void - */ - public function raz() - { - $this->id('RESET'); - $this->ref('RESET'); - $this->qte('RESET'); - $this->stock('RESET'); - $this->remisePercent('RESET'); - $this->amountDiscount('RESET'); - $this->prix('RESET'); - $this->tva('RESET'); - } - - /** - * Resetting persistent attributes - * - * @return void - */ - private function razPers() - { - $this->numInvoice('RESET'); - $this->getSetPaymentMode('RESET'); - $this->amountCollected('RESET'); - $this->amountReturned('RESET'); - $this->paiementLe('RESET'); - - $this->amountWithoutTax('RESET'); - $this->amountVat('RESET'); - $this->amountWithTax('RESET'); - } - - - // Methods for modifying protected attributes - - /** - * Getter for id - * - * @param int $aId Id - * @return int Id - */ - public function id($aId = null) - { - - if (!$aId) { - return $this->id; - } elseif ($aId == 'RESET') { - $this->id = null; - } else { - $this->id = $aId; - } - } - - /** - * Getter for ref - * - * @param string $aRef Ref - * @return string Ref - */ - public function ref($aRef = null) - { - - if (is_null($aRef)) { - return $this->ref; - } elseif ($aRef == 'RESET') { - $this->ref = null; - } else { - $this->ref = $aRef; - } - } - - /** - * Getter for qte - * - * @param int $aQte Qty - * @return int Qty - */ - public function qte($aQte = null) - { - if (is_null($aQte)) { - return $this->qte; - } elseif ($aQte == 'RESET') { - $this->qte = null; - } else { - $this->qte = $aQte; - } - } - - /** - * Getter for stock - * - * @param string $aStock Stock - * @return string Stock - */ - public function stock($aStock = null) - { - - if (is_null($aStock)) { - return $this->stock; - } elseif ($aStock == 'RESET') { - $this->stock = null; - } else { - $this->stock = $aStock; - } - } - - /** - * Getter for remise_percent - * - * @param string $aRemisePercent Discount - * @return string Discount - */ - public function remisePercent($aRemisePercent = null) - { - - if (is_null($aRemisePercent)) { - return $this->remise_percent; - } elseif ($aRemisePercent == 'RESET') { - $this->remise_percent = null; - } else { - $this->remise_percent = $aRemisePercent; - } - } - - /** - * Getter for montant_remise - * - * @param int $aMontantRemise Amount - * @return string Amount - */ - public function amountDiscount($aMontantRemise = null) - { - - if (is_null($aMontantRemise)) { - return $this->montant_remise; - } elseif ($aMontantRemise == 'RESET') { - $this->montant_remise = null; - } else { - $this->montant_remise = $aMontantRemise; - } - } - - /** - * Getter for prix - * - * @param int $aPrix Price - * @return string Stock - */ - public function prix($aPrix = null) - { - - if (is_null($aPrix)) { - return $this->prix; - } elseif ($aPrix == 'RESET') { - $this->prix = null; - } else { - $this->prix = $aPrix; - } - } - - /** - * Getter for tva - * - * @param int $aTva Vat - * @return int Vat - */ - public function tva($aTva = null) - { - if (is_null($aTva)) { - return $this->tva; - } elseif ($aTva == 'RESET') { - $this->tva = null; - } else { - $this->tva = $aTva; - } - } - - /** - * Get num invoice - * - * @param string $aNumFacture Invoice ref - * @return string Invoice ref - */ - public function numInvoice($aNumFacture = null) - { - if (is_null($aNumFacture)) { - return $this->num_facture; - } elseif ($aNumFacture == 'RESET') { - $this->num_facture = null; - } else { - $this->num_facture = $aNumFacture; - } - } - - /** - * Get payment mode - * - * @param int $aModeReglement Payment mode - * @return int Payment mode - */ - public function getSetPaymentMode($aModeReglement = null) - { - - if (is_null($aModeReglement)) { - return $this->mode_reglement; - } elseif ($aModeReglement == 'RESET') { - $this->mode_reglement = null; - } else { - $this->mode_reglement = $aModeReglement; - } - } - - /** - * Get amount - * - * @param int $aMontantEncaisse Amount - * @return int Amount - */ - public function amountCollected($aMontantEncaisse = null) - { - - if (is_null($aMontantEncaisse)) { - return $this->montant_encaisse; - } elseif ($aMontantEncaisse == 'RESET') { - $this->montant_encaisse = null; - } else { - $this->montant_encaisse = $aMontantEncaisse; - } - } - - /** - * Get amount - * - * @param int $aMontantRendu Amount - * @return int Amount - */ - public function amountReturned($aMontantRendu = null) - { - - if (is_null($aMontantRendu)) { - return $this->montant_rendu; - } elseif ($aMontantRendu == 'RESET') { - $this->montant_rendu = null; - } else { - $this->montant_rendu = $aMontantRendu; - } - } - - /** - * Get payment date - * - * @param integer $aPaiementLe Date - * @return integer Date - */ - public function paiementLe($aPaiementLe = null) - { - if (is_null($aPaiementLe)) { - return $this->paiement_le; - } elseif ($aPaiementLe == 'RESET') { - $this->paiement_le = null; - } else { - $this->paiement_le = $aPaiementLe; - } - } - - /** - * Get total HT - * - * @param int $aTotalHt Total amount - * @return int Total amount - */ - public function amountWithoutTax($aTotalHt = null) - { - if (is_null($aTotalHt)) { - return $this->prix_total_ht; - } elseif ($aTotalHt == 'RESET') { - $this->prix_total_ht = null; - } else { - $this->prix_total_ht = $aTotalHt; - } - } - - /** - * Get amount vat - * - * @param int $aMontantTva Amount vat - * @return int Amount vat - */ - public function amountVat($aMontantTva = null) - { - if (is_null($aMontantTva)) { - return $this->montant_tva; - } elseif ($aMontantTva == 'RESET') { - $this->montant_tva = null; - } else { - $this->montant_tva = $aMontantTva; - } - } - - /** - * Get total TTC - * - * @param int $aTotalTtc Amount ttc - * @return int Amount ttc - */ - public function amountWithTax($aTotalTtc = null) - { - if (is_null($aTotalTtc)) { - return $this->prix_total_ttc; - } elseif ($aTotalTtc == 'RESET') { - $this->prix_total_ttc = null; - } else { - $this->prix_total_ttc = $aTotalTtc; - } - } -} diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css deleted file mode 100644 index b17a63e548e..00000000000 --- a/htdocs/cashdesk/css/style.css +++ /dev/null @@ -1,455 +0,0 @@ -/* Copyright (C) 2007-2008 Jeremie Ollivier - * - * 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 . - */ - -body { - background: #fff; - color: #333; - margin: 0; - padding: 0; -} - -p { - margin: 0; -} - -.conteneur { - background: #fff; - text-align: left; - /*max-width: 770px;*/ - /*margin: 10px auto; - border: 2px solid #000;*/ -} - -.conteneur_img_gauche { - /* background: url("../img/bg_conteneur_gauche.png") top left repeat-y; */ -} - -.conteneur_img_droite { - /* background: url("../img/bg_conteneur_droite.png") top right repeat-y; */ -} - -.contenu { - width: 100%; - text-align: center; - padding-top: 20px; -} - -.logo { - text-align: center; -} -.logopos { - padding-top: 20px; - max-height: 40px; -} - -/* ------------------- Header ------------------- */ -.entete { - height: 15px; - margin: 0; - /* background: url('../img/bg_entete.png') no-repeat left top; */ -} - -.entete span { - display: none; -} - -.principal_login td.label1 { - width: 50%; -} - -/* ------------------- Menu ------------------- */ -.menu_principal { - margin: 0; - font-size: 14px; - height: 84px; - background: #CCCCCC; - background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); - background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); - background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); - background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); - background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); - background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(40,40,40,.3)) ); -} - -.menu_bloc { - margin-left: 12px; -} - -.menu { - margin: 0; - list-style-type: none; - padding: 8px 0 0; -} - -.menu li { - float: left; - padding-right: 10px; -} - -.menu_choix0 { - font-size: 10px; - text-align: right; - font-style: italic; - font-weight: normal; - display: block; - color: #333; - text-decoration: none; - padding-right: 5px; -} - -/* Force values for small screen 570 */ -@media only screen and (max-width: 570px) -{ - .menu_choix0 { - max-width: 180px; - } -} - -.menu_choix0 a { - font-weight: normal; - text-decoration: none; -} -li.menu_choix0 { - float: right; -} - -/* ------------------- Remind of products ------------------- */ -.liste_articles { - min-width: 215px; - float: right; - margin-top: 8px; - margin-right: 20px; - border: 1px dotted #5ca64d; - padding-bottom: 10px; - vertical-align: middle; -} - -p.titre { - margin: 0 0 20px; - text-align: center; - font-weight: bold; - font-size: 1.4em; - color: #5ca64d; - border-bottom: 1px dotted; -} - -.cadre_article { - width: 180px; - text-align: center; - margin: 0 auto 10px; - padding-bottom: 10px; - border-bottom: 1px solid #eee; -} - -.cadre_article p { - color: #5ca64d; -} - -.cadre_article p a { - color: #333; - font-size: 1.1em; - text-decoration: none; - padding-right: 25px; - background: url('../img/basket_delete.png') top right no-repeat; -} - -.cadre_article p a:hover { - color: #6d3f6d; -} - -.cadre_aucun_article { - text-align: center; - font-style: italic; -} - -.cadre_prix_total { - text-align: center; - font-weight: bold; - font-size: 1.4em; - color: #6d3f6d; - padding-top: 10px; - padding-bottom: 10px; - margin-left: 20px; - margin-right: 20px; - border: 1px dotted #6d3f6d; -} - -/* ------------------- Contenu ------------------- */ -.principal_login { - margin: 10px; - padding: 0; - max-width: 800px; - text-align: left; -} - -.formulaire_login { - text-align: center; -} - -.formulaire_login table { - padding-left: 60px; - margin: 0 auto 20px; - background: url('../img/login.png') bottom left no-repeat; -} - -.formulaire_login table tr { - height: 30px; -} - -.texte_login { - padding-left: 2px; - padding-right: 2px; - background: #fff; - border: 1px solid #6d3f6d; -} - -.principal { - float: left; - margin: 0 15px; - padding: 0; - max-width: 900px; -} - -.blocksellfinished { - min-width: 215px; - margin-top: 8px; -} -.titre1 { - font-weight: bold; - color: #ff9900; - margin: 0; - font-size: 1.4em; -} - -.label1 { - color: #333; - font-size: 1.1em; -} - -.cadre_facturation { - border: 2px solid #ddd; - margin-bottom: 15px; -} - -.principal p { - padding-left: 10px; - padding-right: 10px; -} - -.lien1 { - color: #333; - font-size: 1.1em; - text-decoration: underline; -} - -.lien1:hover { - color: #6d3f6d; -} - -/* Formulaires */ -.formulaire1 { - padding: 0; -} - - -/* --------------------- Combo lists ------------------- */ -.select_design { - overflow: auto; -} - -.select_design select { - border: 1px solid #6d3f6d; - font: 12px verdana,arial,helvetica; - background: #fff; -} - -.select_tva select { - width: 60px; - border: 1px solid #6d3f6d; - background: #fff; -} - -.top_liste { - font-style: italic; - text-align: center; - color: #aaa; -} - -/* --------------- Champs texte ---------------- */ -.texte_ref,.texte1,.texte1_off,.texte2,.texte2_off,.textarea_note { - padding-left: 2px; - padding-right: 2px; -} - -.texte_ref,.texte1,.texte2,.textarea_note { - background: #fff; - border: 1px solid #6d3f6d; -} - -.texte1_off,.texte2_off { - color: #000; - border: 1px solid #eee; - background: #eee; -} - -.texte_ref { - min-width: 150px; -} - -.texte1,.texte1_off { - width: 60px; -} - -.texte2,.texte2_off { - width: 140px; -} - -/* ------------------- */ -.textarea_note { - width: 100%; - height: 50px; - padding: 2px 2px; -} - -/* -------------- Buttons for SimplePOS --------------------- */ -.bouton_ajout_article { - margin-top: 10px; - width: 60%; - height: 40px; -} - -.bouton_mode_reglement, .bouton_mode_reglement_disabled { - width: 150px; - height: 40px; -} - -.bouton_validation { /* width: 80px; */ - margin-left: 10px; - margin-top: 20px; - margin-bottom: 10px; -} - -.formulaire2 { - padding: 0; - width: 100%; -} - -.table_resume { - width: 100%; -} - -.table_resume tr { - background: #eee; -} - -.table_resume td { - padding-left: 8px; -} - -.resume_label,.note_label { - min-width: 200px; - font-weight: bold; - font-size: 1.1em; -} - -.note_label { - padding-top: 20px; -} - -/* ------------------- Pied de page ------------------- */ -.pied { - clear: both; - height: 15px; - /* background: url('../img/bg_pied.png') no-repeat bottom left; */ -} - -/* ------------------- Param�tres communs (messages d'erreur, informations, etc...) ------------------- */ -.msg_err1 { - color: #c00; -} - -/* Messages d'erreur */ -.cadre_err1 { - margin-right: 10px; - margin-bottom: 10px; - padding: 10px 10px; - border: 1px solid #c00; - background: #feffac; - color: #c00; -} - -/* Titre */ -.err_titre { - font-weight: bold; - margin: 0 0 10px; - padding: 0; -} - -/* Description */ -.err_desc { - margin: 0; - padding: 0; -} - -/* Messages d'information */ -.cadre_msg1 { - margin-right: 10px; - margin-bottom: 10px; - padding: 10px 10px; - border: 1px solid #070; - background: #e8f8da; - color: #070; -} - -/* Titre */ -.msg_titre { - font-weight: bold; - margin: 0 0 10px; - padding: 0; -} - -/* Description */ -.msg_desc { - margin: 0; - padding: 0; -} - -/* Affichage de la liste des resultats */ -.dhtml_bloc { - margin: 0; - padding: 3px; - font-size: 13px; - font-family: arial, sans-serif; - border: 1px solid #000; - z-index: 1; - width: 455px; - max-height: 500px; - overflow: auto; - position: absolute; - background-color: white; -} - -.dhtml_defaut { - list-style-type: none; - display: block; - height: 16px; - overflow: hidden; -} - -.dhtml_selection { - background-color: #3366cc; - color: white ! important; -} diff --git a/htdocs/cashdesk/css/ticket.css b/htdocs/cashdesk/css/ticket.css deleted file mode 100644 index 248e0f7b9b6..00000000000 --- a/htdocs/cashdesk/css/ticket.css +++ /dev/null @@ -1,61 +0,0 @@ -/* - * TPV ticket.css - */ -body { - font-size: 1.5em; - position: relative; -} - -.entete { /* position: relative; */ - -} - -.address { /* float: left; */ - font-size: 12px; -} - -.date_heure { - position: absolute; - top: 0; - right: 0; - font-size: 16px; -} - -.infos { - position: relative; -} - -.liste_articles { - width: 100%; - border-bottom: 1px solid #000; - text-align: center; -} - -.liste_articles tr.titres th { - border-bottom: 1px solid #000; -} - -.liste_articles td.total { - text-align: right; -} - -.totaux { - margin-top: 20px; - width: 30%; - float: right; - text-align: right; -} - -.lien { - position: absolute; - top: 0; - left: 0; - display: none; -} - -@media print { - .lien { - display: none; - } -} - diff --git a/htdocs/cashdesk/deconnexion.php b/htdocs/cashdesk/deconnexion.php deleted file mode 100644 index f7506902ab5..00000000000 --- a/htdocs/cashdesk/deconnexion.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/deconnexion.php - * \ingroup cashdesk - * \brief Manage deconnexion for point of sale module - */ - -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); -} -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} - -require_once '../main.inc.php'; - -// This destroy tag that say "Point of Sale session is on". -unset($_SESSION['uid']); - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - -header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php'); -exit; diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php deleted file mode 100644 index edce8acd781..00000000000 --- a/htdocs/cashdesk/facturation.php +++ /dev/null @@ -1,159 +0,0 @@ - - * Copyright (C) 2008-2011 Laurent Destailleur - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2013 Marcos García - * Copyright (C) 2013 Adolfo Segura - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/facturation.php - * \ingroup cashdesk - * \brief Include to show main page for cashdesk module - */ - - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * View - */ - -$form = new Form($db); - -// Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled) -if (GETPOST('filtre', 'alpha')) { - // Avec filtre - $ret = array(); $i = 0; - - $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= ", ps.reel"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'"; - } - $sql .= " WHERE p.entity IN (".getEntity('product').")"; - $sql .= " AND p.tosell = 1"; - if (!$conf->global->CASHDESK_SERVICES) { - $sql .= " AND p.fk_product_type = 0"; - } - $sql .= " AND ("; - $sql .= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; - if (!empty($conf->barcode->enabled)) { - $filtre = GETPOST('filtre', 'alpha'); - - //If the barcode looks like an EAN13 format and the last digit is included in it, - //then whe look for the 12-digit too - //As the twelve-digit string will also hit the 13-digit code, we only look for this one - if (strlen($filtre) == 13) { - $crit_12digit = substr($filtre, 0, 12); - $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'"; - } else { - $sql .= " OR p.barcode LIKE '%".$db->escape($filtre)."%'"; - } - } - $sql .= ")"; - $sql .= " ORDER BY label"; - - dol_syslog("facturation.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $nbr_enreg = $db->num_rows($resql); - - while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) { - foreach ($tab as $cle => $valeur) { - $ret[$i][$cle] = $valeur; - } - $i++; - } - $db->free($resql); - } else { - dol_print_error($db); - } - $tab_designations = $ret; -} else { - // Sans filtre - $ret = array(); - $i = 0; - - $sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= ", ps.reel"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'"; - } - $sql .= " WHERE p.entity IN (".getEntity('product').")"; - $sql .= " AND p.tosell = 1"; - if (!$conf->global->CASHDESK_SERVICES) { - $sql .= " AND p.fk_product_type = 0"; - } - $sql .= " ORDER BY p.label"; - - dol_syslog($sql); - $resql = $db->query($sql); - if ($resql) { - $nbr_enreg = $db->num_rows($resql); - - while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) { - foreach ($tab as $cle => $valeur) { - $ret[$i][$cle] = $valeur; - } - $i++; - } - $db->free($resql); - } else { - dol_print_error($db); - } - $tab_designations = $ret; -} - -//$nbr_enreg = count($tab_designations); - -if ($nbr_enreg > 1) { - if ($nbr_enreg > $conf_taille_listes) { - $top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----'; - } else { - $top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----'; - } -} elseif ($nbr_enreg == 1) { - $top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound").' -----'; -} else { - $top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound").' -----'; -} - - -// Recuperation des taux de tva -global $mysoc; - -$ret = array(); -$i = 0; - -// Reinitialisation du mode de paiement, en cas de retour aux achats apres validation -$obj_facturation->getSetPaymentMode('RESET'); -$obj_facturation->amountCollected('RESET'); -$obj_facturation->amountReturned('RESET'); -$obj_facturation->paiementLe('RESET'); - - -// Affichage des templates -require 'tpl/facturation1.tpl.php'; diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php deleted file mode 100644 index 3d0e9ff84ec..00000000000 --- a/htdocs/cashdesk/facturation_dhtml.php +++ /dev/null @@ -1,129 +0,0 @@ - - * Copyright (C) 2008-2009 Laurent Destailleur - * Copyright (C) 2015 Regis Houssin - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/facturation_dhtml.php - * \ingroup cashdesk - * \brief This page is called each time we press a key in the code search form to show product combo list. - */ - - -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); -} -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); -} -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} - -// Change this following line to use the correct relative path (../, ../../, etc) -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * View - */ - -top_httphead('text/html'); - -$search = GETPOST("code", "alpha"); - -// Search from criteria -if (dol_strlen($search) >= 0) { // If search criteria is on char length at least - $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= ", ps.reel"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'"; - } - $sql .= " WHERE p.entity IN (".getEntity('product').")"; - $sql .= " AND p.tosell = 1"; - $sql .= " AND p.fk_product_type = 0"; - // Add criteria on ref/label - if (!empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) { - $sql .= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'"; - if (!empty($conf->barcode->enabled)) { - $sql .= " OR p.barcode LIKE '".$db->escape($search)."%'"; - } - $sql .= ")"; - } else { - $sql .= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'"; - if (!empty($conf->barcode->enabled)) { - $sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'"; - } - $sql .= ")"; - } - $sql .= " ORDER BY label"; - - dol_syslog("facturation_dhtml.php", LOG_DEBUG); - $result = $db->query($sql); - - if ($result) { - if ($nbr = $db->num_rows($result)) { - $resultat = '
      '; - - $ret = array(); $i = 0; - while ($tab = $db->fetch_array($result)) { - foreach ($tab as $cle => $valeur) { - $ret[$i][$cle] = $valeur; - } - $i++; - } - $tab = $ret; - - $tab_size = count($tab); - for ($i = 0; $i < $tab_size; $i++) { - $resultat .= ' -
    • '.$tab[$i]['ref'].' - '.$tab[$i]['label'].'
    • - '; - } - - $resultat .= '
    '; - - print $resultat; - } else { - $langs->load("cashdesk"); - - print '
      '; - print '
    • '.$langs->trans("NoResults").'
    • '; - print '
    '; - } - } -} diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php deleted file mode 100644 index f51cda3e77b..00000000000 --- a/htdocs/cashdesk/facturation_verif.php +++ /dev/null @@ -1,225 +0,0 @@ - - * Copyright (C) 2008-2010 Laurent Destailleur - * Copyright (C) 2018 Juanjo Menent - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/facturation_verif.php - * \ingroup cashdesk - * \brief facturation_verif.php - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -$action = GETPOST('action', 'aZ09'); - -$obj_facturation = unserialize($_SESSION['serObjFacturation']); -unset($_SESSION['serObjFacturation']); - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * View - */ - -switch ($action) { - default: - if (GETPOST('hdnSource') != 'NULL') { - $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= ", ps.reel"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".((int) $conf_fkentrepot); - } - $sql .= " WHERE p.entity IN (".getEntity('product').")"; - - // Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ... - if ($_POST['hdnSource'] == 'LISTE') { - $sql .= " AND p.rowid = ".((int) GETPOST('selProduit', 'int')); - } elseif ($_POST['hdnSource'] == 'REF') { - $sql .= " AND p.ref = '".$db->escape(GETPOST('txtRef', 'alpha'))."'"; - } - - $result = $db->query($sql); - if ($result) { - // ... et enregistrement dans l'objet - if ($db->num_rows($result)) { - $ret = array(); - $tab = $db->fetch_array($result); - foreach ($tab as $key => $value) { - $ret[$key] = $value; - } - // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function - - $productid = $ret['rowid']; - $product = new Product($db); - $product->fetch($productid); - $prod = $product; - - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); - $societe->fetch($thirdpartyid); - - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $societe, $product->id); - $tva_npr = get_default_npr($mysoc, $societe, $product->id); - if (empty($tva_tx)) { - $tva_npr = 0; - } - - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - - // multiprix - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) { - $pu_ht = $prod->multiprices[$societe->price_level]; - $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; - $price_min = $prod->multiprices_min[$societe->price_level]; - $price_base_type = $prod->multiprices_base_type[$societe->price_level]; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility - if (isset($prod->multiprices_tva_tx[$societe->price_level])) { - $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; - } - if (isset($prod->multiprices_recuperableonly[$societe->price_level])) { - $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; - } - } - } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { - $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; - } - $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) { - $tva_npr = 0; - } - } - } else { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } - } - - $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); - $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - - // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } elseif ($tmpvat != $tmpprodvat) { - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - } - - $obj_facturation->id($ret['rowid']); - $obj_facturation->ref($ret['ref']); - $obj_facturation->stock($ret['reel']); - //$obj_facturation->prix($ret['price']); - $obj_facturation->prix($pu_ht); - - - $vatrate = $tva_tx; - $obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code) - - // Definition du filtre pour n'afficher que le produit concerne - if (GETPOST('hdnSource') == 'LISTE') { - $filtre = $ret['ref']; - } elseif (GETPOST('hdnSource') == 'REF') { - $filtre = GETPOST('txtRef'); - } - - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.urlencode($filtre); - } else { - $obj_facturation->raz(); - - if (GETPOST('hdnSource') == 'REF') { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.urlencode(GETPOST('txtRef')); - } else { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - } - } - } else { - dol_print_error($db); - } - } else { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - } - - break; - - case 'change_thirdparty': // We have clicked on button "Modify" a thirdparty - $newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int'); - if ($newthirdpartyid > 0) { - $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; - } - - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - break; - - case 'ajout_article': - if (!empty($obj_facturation->id)) { // A product was previously selected and stored in session, so we can add it - dol_syslog("facturation_verif save vat ".GETPOST('selTva')); - $obj_facturation->qte(GETPOST('txtQte')); - $obj_facturation->tva(GETPOST('selTva')); // id of vat. Saved so we can use it for next product - $obj_facturation->remisePercent(GETPOST('txtRemise')); - $obj_facturation->ajoutArticle(); // This add an entry into $_SESSION['poscart'] - // We update prixTotalTtc - } - - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - break; - - case 'suppr_article': - $obj_facturation->supprArticle(GETPOST('suppr_id')); - - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - break; -} - -// We saved object obj_facturation -$_SESSION['serObjFacturation'] = serialize($obj_facturation); -//var_dump($_SESSION['serObjFacturation']); -header('Location: '.$redirection); -exit; diff --git a/htdocs/cashdesk/img/basket_delete.png b/htdocs/cashdesk/img/basket_delete.png deleted file mode 100644 index 9419d91d9f1..00000000000 Binary files a/htdocs/cashdesk/img/basket_delete.png and /dev/null differ diff --git a/htdocs/cashdesk/img/bg_conteneur_droite.png b/htdocs/cashdesk/img/bg_conteneur_droite.png deleted file mode 100644 index 87d7fcf069a..00000000000 Binary files a/htdocs/cashdesk/img/bg_conteneur_droite.png and /dev/null differ diff --git a/htdocs/cashdesk/img/bg_conteneur_gauche.png b/htdocs/cashdesk/img/bg_conteneur_gauche.png deleted file mode 100644 index a6da5629413..00000000000 Binary files a/htdocs/cashdesk/img/bg_conteneur_gauche.png and /dev/null differ diff --git a/htdocs/cashdesk/img/bg_entete.png b/htdocs/cashdesk/img/bg_entete.png deleted file mode 100644 index 0c7670509bc..00000000000 Binary files a/htdocs/cashdesk/img/bg_entete.png and /dev/null differ diff --git a/htdocs/cashdesk/img/bg_pied.png b/htdocs/cashdesk/img/bg_pied.png deleted file mode 100644 index 36a38a42ced..00000000000 Binary files a/htdocs/cashdesk/img/bg_pied.png and /dev/null differ diff --git a/htdocs/cashdesk/img/calendrier.png b/htdocs/cashdesk/img/calendrier.png deleted file mode 100644 index 7ac67ea96b3..00000000000 Binary files a/htdocs/cashdesk/img/calendrier.png and /dev/null differ diff --git a/htdocs/cashdesk/img/decrypted.png b/htdocs/cashdesk/img/decrypted.png deleted file mode 100644 index 8d2b4696a2b..00000000000 Binary files a/htdocs/cashdesk/img/decrypted.png and /dev/null differ diff --git a/htdocs/cashdesk/img/gescom.png b/htdocs/cashdesk/img/gescom.png deleted file mode 100644 index 0ec1639335e..00000000000 Binary files a/htdocs/cashdesk/img/gescom.png and /dev/null differ diff --git a/htdocs/cashdesk/img/lock.png b/htdocs/cashdesk/img/lock.png deleted file mode 100644 index 55258949069..00000000000 Binary files a/htdocs/cashdesk/img/lock.png and /dev/null differ diff --git a/htdocs/cashdesk/img/login.png b/htdocs/cashdesk/img/login.png deleted file mode 100644 index 600cb67dd0a..00000000000 Binary files a/htdocs/cashdesk/img/login.png and /dev/null differ diff --git a/htdocs/cashdesk/img/new.png b/htdocs/cashdesk/img/new.png deleted file mode 100644 index ed848a86550..00000000000 Binary files a/htdocs/cashdesk/img/new.png and /dev/null differ diff --git a/htdocs/cashdesk/include/environnement.php b/htdocs/cashdesk/include/environnement.php deleted file mode 100644 index fc67c65ea4c..00000000000 --- a/htdocs/cashdesk/include/environnement.php +++ /dev/null @@ -1,50 +0,0 @@ - - * Copyright (C) 2009-2011 Laurent Destailleur - * Copyright (C) 2011 Juanjo Menent - * - * 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 . - */ - -// This file initializes more variables to already initialized variables with main.inc.php -// So include of this file must be always done after include to main.inc.php - -$conf_db_type = $dolibarr_main_db_type; - -// Parametres de connexion a la base -$conf_db_host = $dolibarr_main_db_host; -$conf_db_user = $dolibarr_main_db_user; -$conf_db_pass = $dolibarr_main_db_pass; -$conf_db_base = $dolibarr_main_db_name; - -// Identifiant unique correspondant au tiers generique pour la vente -$conf_fksoc = (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) ? $_SESSION["CASHDESK_ID_THIRDPARTY"] : ($conf->global->CASHDESK_ID_THIRDPARTY > 0 ? $conf->global->CASHDESK_ID_THIRDPARTY : 0); -// Identifiant unique correspondant a l'entrepot a utiliser -$conf_fkentrepot = (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"])) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : ($conf->global->CASHDESK_ID_WAREHOUSE > 0 ? $conf->global->CASHDESK_ID_WAREHOUSE : 0); -if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { - $conf_fkentrepot = 0; // If option to disable the stock decrease is on, we set warehouse id to 0. -} - -// Identifiant unique correspondant au compte caisse / liquide -$conf_fkaccount_cash = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CASH : 0); -// Identifiant unique correspondant au compte cheque -$conf_fkaccount_cheque = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE : 0); -// Identifiant unique correspondant au compte cb -$conf_fkaccount_cb = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CB : 0); -//var_dump($_SESSION); - - -// View parameters -$conf_taille_listes = (empty($conf->global->PRODUIT_LIMIT_SIZE) ? 1000 : $conf->global->PRODUIT_LIMIT_SIZE); // Number max of lines to show in lists -$conf_nbr_car_listes = 60; // Nombre max de caracteres par ligne dans les listes diff --git a/htdocs/cashdesk/include/keypad.php b/htdocs/cashdesk/include/keypad.php deleted file mode 100644 index 6e4c9c874d6..00000000000 --- a/htdocs/cashdesk/include/keypad.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * 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 . - */ - -/** - * Return a string to output a keypad - * - * @param string $keypadname Key pad name - * @param string $formname Form name - * @return string HTML code to show a js keypad. - */ -function genkeypad($keypadname, $formname) -{ - global $conf; - - if (empty($conf->global->CASHDESK_SHOW_KEYPAD)) { - return ''; - } - - // défine the font size of button - $btnsize = 32; - $sz = ''."\n"; - $sz .= '
    '."\n"; - $sz .= ''; - return $sz; -} diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php deleted file mode 100644 index a4ee6fa415c..00000000000 --- a/htdocs/cashdesk/index.php +++ /dev/null @@ -1,232 +0,0 @@ - - * Copyright (C) 2011-2017 Juanjo Menent - * Copyright (C) 2011 Laurent Destailleur - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/index.php - * \ingroup cashdesk - * \brief File to login to point of sales - */ - -// Set and init common variables -// This include will set: config file variable $dolibarr_xxx, $conf, $langs and $mysoc objects -require_once '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("admin", "cashdesk")); - -// Test if user logged -if ($_SESSION['uid'] > 0) { - header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php'); - exit; -} - -$usertxt = GETPOST('user', '', 1); -$err = GETPOST("err"); - -// Instantiate hooks of thirdparty module only if not already define -$hookmanager->initHooks(array('cashdeskloginpage')); - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * View - */ - -$form = new Form($db); -$formproduct = new FormProduct($db); - -$arrayofcss = array('/cashdesk/css/style.css'); -top_htmlhead('', '', 0, 0, '', $arrayofcss); - -// Execute hook getLoginPageOptions (for table) -$parameters = array('entity' => GETPOST('entity', 'int')); -$reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks. -if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) { - $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility -} else { - $morelogincontent = $hookmanager->resPrint; -} -?> - - -
    -
    -
    - - - -
    -
    - -
    -
    - -
    -
    -
    - - -'; diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php deleted file mode 100644 index 94e0e7009cf..00000000000 --- a/htdocs/cashdesk/index_verif.php +++ /dev/null @@ -1,126 +0,0 @@ - - * Copyright (C) 2008-2010 Laurent Destailleur - * Copyright (C) 2011 Juanjo Menent - * - * 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 . - * - * This page is called after submission of login page. - * We set here login choices into session. - */ - -/** - * \file htdocs/cashdesk/index_verif.php - * \ingroup cashdesk - * \brief index_verif.php - */ - -include '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Auth.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("admin", "cashdesk")); - -$username = GETPOST("txtUsername"); -$password = GETPOST("pwdPassword"); -$thirdpartyid = (GETPOST('socid', 'int') > 0) ?GETPOST('socid', 'int') : $conf->global->CASHDESK_ID_THIRDPARTY; -$warehouseid = (GETPOST("warehouseid") > 0) ?GETPOST("warehouseid", 'int') : $conf->global->CASHDESK_ID_WAREHOUSE; -$bankid_cash = (GETPOST("CASHDESK_ID_BANKACCOUNT_CASH") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CASH", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; -$bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; -$bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CB", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB; - - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -// Check username -if (empty($username)) { - $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; -} -// Check third party id -if (!($thirdpartyid > 0)) { - $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; -} - -// If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished. -if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0)) { - $retour = $langs->trans("CashDeskYouDidNotDisableStockDecease"); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; -} - -// If stock decrease on bill validation, check user has stock edit permissions -if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username)) { - $testuser = new User($db); - $testuser->fetch(0, $username); - $testuser->getrights('stock'); - if (empty($testuser->rights->stock->creer)) { - $retour = $langs->trans("UserNeedPermissionToEditStockToUsePos"); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; - } -} - - -// Check password -$auth = new Auth($db); -$retour = $auth->verif($username, $password); - -if ($retour >= 0) { - $return = array(); - - $sql = "SELECT rowid, lastname, firstname"; - $sql .= " FROM ".MAIN_DB_PREFIX."user"; - $sql .= " WHERE login = '".$db->escape($username)."'"; - $sql .= " AND entity IN (0,".$conf->entity.")"; - - $result = $db->query($sql); - if ($result) { - $tab = $db->fetch_array($res); - - foreach ($tab as $key => $value) { - $return[$key] = $value; - } - - $_SESSION['uid'] = $tab['rowid']; - $_SESSION['uname'] = $username; - $_SESSION['lastname'] = $tab['lastname']; - $_SESSION['firstname'] = $tab['firstname']; - $_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : ''); - $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); - - $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); - //var_dump($_SESSION);exit; - - header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV'); - exit; - } else { - dol_print_error($db); - } -} else { - // Load translation files required by the page - $langs->loadLangs(array("other", "errors")); - $retour = $langs->trans("ErrorBadLoginPassword"); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid); - exit; -} diff --git a/htdocs/cashdesk/javascript/dhtml.js b/htdocs/cashdesk/javascript/dhtml.js deleted file mode 100644 index fd15704b318..00000000000 --- a/htdocs/cashdesk/javascript/dhtml.js +++ /dev/null @@ -1,73 +0,0 @@ - -/* Copyright (C) 2007-2008 Jeremie Ollivier - * Copyright (C) 2015 Regis Houssin - * - * 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 . - */ - -// Instanciation et initialisation de l'objet xmlhttprequest -function file(fichier) { - - // Instanciation de l'objet pour Mozilla, Konqueror, Opera, Safari, etc ... - if (window.XMLHttpRequest) { - - xhr_object = new XMLHttpRequest (); - - // ... ou pour IE - } else if (window.ActiveXObject) { - - xhr_object = new ActiveXObject ("Microsoft.XMLHTTP"); - - } else { - - return (false); - - } - - xhr_object.open ("GET", fichier, false); - xhr_object.send (null); - - if (xhr_object.readyState == 4) { - - return (xhr_object.responseText); - - } else { - - return (false); - - } - -} - - -// aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage -function verifResultat(aCible, aCode, iLimit) { - if (aCode != '' && aCode.length >= iLimit) { - - if (texte = file('facturation_dhtml.php?code='+escape(aCode))) { - document.getElementById(aCible).innerHTML = texte; - } else - document.getElementById(aCible).innerHTML = ''; - } - -} - - -// Change dynamiquement la classe de l'element ayant l'id aIdElement pour aClasse -function setStyle(aIdElement, aClasse) { - - aIdElement.className = aClasse; - -} - diff --git a/htdocs/cashdesk/javascript/facturation1.js b/htdocs/cashdesk/javascript/facturation1.js deleted file mode 100644 index b25a1473c53..00000000000 --- a/htdocs/cashdesk/javascript/facturation1.js +++ /dev/null @@ -1,175 +0,0 @@ - -/* Copyright (C) 2007-2008 Jeremie Ollivier - * - * 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 . - */ - -// Calcul et affichage en temps reel des informations sur le produit en cours -function modif() { - - var prix_unit = parseFloat ( document.getElementById('frmQte').txtPrixUnit.value ); - var qte = parseFloat ( document.getElementById('frmQte').txtQte.value ); - var _index = parseFloat ( document.getElementById('frmQte').selTva.selectedIndex ); - var tva = parseFloat ( document.getElementById('frmQte').selTva.options[_index].text ); - var remise = parseInt ( document.getElementById('frmQte').txtRemise.value ); - var stock = document.getElementById('frmQte').txtStock.value; - -// // On s'assure que la quantitee tapee ne depasse pas le stock -// if ( qte > stock ) { -// -// qte = stock; -// document.getElementById('frmQte').txtQte.value = qte; -// -// } -// -// if ( qte < 1 ) { -// -// qte = 1; -// document.getElementById('frmQte').txtQte.value = qte; -// -// } -// -// if ( !stock || stock <= 0 ) { -// -// qte = 0; -// document.getElementById('frmQte').txtQte.value = qte; -// -// } - - // Calcul du total HT, sans remise - var total_ht = Math.round ( (prix_unit * qte) * 100 ) / 100; - - // Calcul du montant de la remise, apres s'etre assure que cette derniere ne soit pas negative - if ( remise <= 0 ) { - - document.getElementById('frmQte').txtRemise.value = 0; - montant_remise = 0; - - } else { - - var montant_remise = total_ht * remise / 100; - - } - - // Recalcul du montant total, avec la remise - var total = Math.round ( (total_ht - montant_remise) *100 ) / 100; - - // Affichage du resultat dans le formulaire - document.getElementById('frmQte').txtTotal.value = total.toFixed(2); - -} - -// Affecte la source de la requete (liste deroulante ou champ texte 'ref') au champ cache -function setSource(aSrc) { - - document.getElementById('frmFacturation').hdnSource.value = aSrc; - document.getElementById('frmFacturation').submit(); - -} - -// Verification de la coherence des informations saisies dans le formulaire de choix du nombre d'articles -function verifSaisie() { - - if ( document.getElementById('frmQte').txtQte.value ) { - - return true; - - } else { - - document.getElementById('frmQte').txtQte.focus(); - return false; - - } - -} - -// Verification de la coherence des informations saisies dans le formulaire de calcul de la difference -function verifDifference() { - - var du = parseFloat ( document.getElementById('frmDifference').txtDu.value ); - var encaisse = parseFloat ( document.getElementById('frmDifference').txtEncaisse.value ); - - if (encaisse > du) { - - resultat = Math.round ( (encaisse - du) * 100 ) / 100; - document.getElementById('frmDifference').txtRendu.value = resultat.toFixed(2); - - } else if (encaisse == du) { - - document.getElementById('frmDifference').txtRendu.value = '0'; - - } else { - - document.getElementById('frmDifference').txtRendu.value = '-'; - - } - -} - -// Affecte le moyen de paiement (ESP, CB ou CHQ) au champ cache en fonction du bouton clique -function verifClic(aChoix) { - - document.getElementById('frmDifference').hdnChoix.value = aChoix; - -} - -// Determination du moyen de paiement, et validation du formulaire si les donnees sont coherentes -function verifReglement() { - - var choix = document.getElementById('frmDifference').hdnChoix.value; - var du = parseFloat (document.getElementById('frmDifference').txtDu.value); - var encaisse = parseFloat (document.getElementById('frmDifference').txtEncaisse.value); - - if ( du > 0 ) { - - if ( choix == 'ESP' ) { - - if ( encaisse != 0 && encaisse >= du ) { - - return true; - - } else { - - document.getElementById('frmDifference').txtEncaisse.select(); - document.getElementById('frmDifference').txtEncaisse.focus(); - return false; - - } - - } else if ( choix == 'DIF' ) { - - if ( document.getElementById('frmDifference').txtDatePaiement.value ) { - - return true; - - } else { - - document.getElementById('frmDifference').txtDatePaiement.select(); - document.getElementById('frmDifference').txtDatePaiement.focus(); - return false; - - } - - } else { - - return true; - - } - - } else { - - return false; - - } -} diff --git a/htdocs/cashdesk/javascript/keypad.js b/htdocs/cashdesk/javascript/keypad.js deleted file mode 100644 index 48d8491e8bc..00000000000 --- a/htdocs/cashdesk/javascript/keypad.js +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2014 Charles-FR BENKE - * - * 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 . - */ - -function closekeypad(keypadname) -{ - document.getElementById('keypad'+keypadname).style.display='none'; - document.getElementById('closekeypad'+keypadname).style.display='none'; - document.getElementById('openkeypad'+keypadname).style.display='inline-block'; -} -function openkeypad(keypadname) -{ - document.getElementById('keypad'+keypadname).style.display='inline-block'; - document.getElementById('closekeypad'+keypadname).style.display='inline-block'; - document.getElementById('openkeypad'+keypadname).style.display='none'; -} -function addvalue(keypadname, formname, valueToAdd) -{ - myform=document.forms[formname]; - if (myform.elements[keypadname].value=="0") - myform.elements[keypadname].value=""; - myform.elements[keypadname].value+=valueToAdd; - modif(); -} diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php deleted file mode 100644 index 41a0f0b757e..00000000000 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ /dev/null @@ -1,225 +0,0 @@ - - * Copyright (C) 2011 Laurent Destailleur - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2015 Regis Houssin - * Copyright (C) 2018 Frédéric France - * - * 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 . - * - */ - -// Protection to avoid direct call of template -if (empty($langs) || !is_object($langs)) { - print "Error, template page can't be called as URL"; - exit; -} - -// Load translation files required by the page -$langs->loadLangs(array("main", "bills", "cashdesk")); - -// Object $form must de defined - -?> - - - - - - -
    trans("Article"); ?> -
    - - - - - - - - - - - - -
    trans("FilterRefOrLabelOrBC"); ?>trans("Designation"); ?>
    - - -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    trans("Qty"); ?>trans("PriceUHT"); ?>trans("Discount"); ?> (%)trans("VATRate"); ?>
    - - - - - vatrate; // To get vat rate we just have selected - - $buyer = new Societe($db); - if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) { - $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); - } - echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1); - ?> -
    trans("Stock"); ?> - - trans("TotalHT"); ?>
    - - " /> -
    -
    - - -
    - - -
    trans("Amount"); ?> - - - - - - - - - - - -
    trans("TotalTicket"); ?>trans("Received"); ?>trans("Change"); ?>
    - -
    -
    - -
    trans("PaymentMode"); ?> -
    - '; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) { - $langs->load("errors"); - print 'transnoentitiesnoconv("CashDesk"))).'" />'; - } else { - print ''; - } - print '
    '; - print '
    '; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { - $langs->load("errors"); - print 'transnoentitiesnoconv("CashDesk"))).'" />'; - } else { - print ''; - } - print '
    '; - print '
    '; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { - $langs->load("errors"); - print 'transnoentitiesnoconv("CashDesk")).'" />'; - } else { - print ''; - } - print '
    '; - print '
    '; - print '
    '; - ?> - " onclick="javascript: verifClic('DIF');" /> - trans("DateDue").' :'; - print $form->selectDate(-1, 'txtDatePaiement', 0, 0, 0, 'paymentmode', 1, 0); - print '
    '; - ?> -
    -
    -
    - - diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php deleted file mode 100644 index 74be200945f..00000000000 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ /dev/null @@ -1,73 +0,0 @@ - - * Copyright (C) 2011 Juanjo Menent - * - * 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 . - * - */ - -// Protection to avoid direct call of template -if (empty($langs) || !is_object($langs)) { - print "Error, template page can't be called as URL"; - exit; -} - - -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("main", "bills", "cashdesk")); - -?> - -
    -
    - -

    trans("ShoppingCart"); ?>

    - -fetch($thirdpartyid); -/** end add Ditto */ - -$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); - -$tab_size = count($tab); -if ($tab_size <= 0) { - print '
    '.$langs->trans("NoArticle").'

    '; -} else { - for ($i = 0; $i < $tab_size; $i++) { - echo ('
    '."\n"); - echo ('

    '.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

    '."\n"); - - if ($tab[$i]['remise_percent'] > 0) { - $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; - } else { - $remise_percent = ''; - } - - $remise = $tab[$i]['remise']; - - echo ('

    '.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT").' ('.price(price2num($tab[$i]['total_ttc'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC").')

    '."\n"); - echo ('
    '."\n"); - } -} - -echo ('

    '.$langs->trans("Total").' : '.price(price2num($total_ttc, 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'

    '."\n"); - -?>
    -
    diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php deleted file mode 100644 index 67891aa67cf..00000000000 --- a/htdocs/cashdesk/tpl/menu.tpl.php +++ /dev/null @@ -1,90 +0,0 @@ - - * Copyright (C) 2008-2010 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2017 Juanjo Menent - * Copyright (C) 2012 Marcos García - * - * 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 . - */ - -// Protection to avoid direct call of template -if (empty($langs) || !is_object($langs)) { - print "Error, template page can't be called as URL"; - exit; -} - - -include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; - -/*if (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) -{ - $company=new Societe($db); - $company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); - $companyLink = $company->getNomUrl(1); -}*/ -if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { - $bankcash = new Account($db); - $bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]); - $bankcash->label = $bankcash->ref; - $bankcashLink = $bankcash->getNomUrl(1); -} -if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { - $bankcb = new Account($db); - $bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]); - $bankcbLink = $bankcb->getNomUrl(1); -} -if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { - $bankcheque = new Account($db); - $bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]); - $bankchequeLink = $bankcheque->getNomUrl(1); -} -if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) { - $warehouse = new Entrepot($db); - $warehouse->fetch($_SESSION["CASHDESK_ID_WAREHOUSE"]); - $warehouseLink = $warehouse->getNomUrl(1); -} - -// Load translation files required by the page -$langs->loadLangs(array("main", "cashdesk")); - -print "\n".''."\n"; -print ''; -print "\n".''."\n"; diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php deleted file mode 100644 index 9220e3daad4..00000000000 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ /dev/null @@ -1,119 +0,0 @@ - - * Copyright (C) 2011 Laurent Destailleur - * Copyright (C) 2012 Marcos García - * - * 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 . - */ - -// Protection to avoid direct call of template -if (empty($langs) || !is_object($langs)) { - print "Error, template page can't be called as URL"; - exit; -} - - -include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("main", "cashdesk")); - -top_httphead('text/html'); - -$facid = GETPOST('facid', 'int'); -$object = new Facture($db); -$object->fetch($facid); - -?> - - - <?php echo $langs->trans('PrintTicket') ?> - - - - - -
    - -
    -

    name; ?>
    -
    -

    - -

    '; - print $object->ref; - ?>

    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - -
    trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>
    currency); ?>
    - - - - - - - - - - - - -
    trans("TotalHT"); ?>amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>
    trans("TotalVAT").''.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>
    trans("TotalTTC").''.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>
    - - - -trans("Close"); ?> - - diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php deleted file mode 100644 index c2a9124f300..00000000000 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ /dev/null @@ -1,118 +0,0 @@ - - * Copyright (C) 2011 Juanjo Menent - * - * 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 . - */ - -// Protection to avoid direct call of template -if (empty($langs) || !is_object($langs)) { - print "Error, template page can't be called as URL"; - exit; -} - -// Load translation files required by the page -$langs->loadLangs(array("main", "bills", "banks")); - -// Object $form must de defined - -?> - -
    trans("Summary"); ?> - - - - - -amountVat()) { - echo (''); -} else { - echo (''); -} -?> - - - -getsetPaymentMode() == 'DIF') { - echo (''); -} else { - echo (''); -} - -// Affichage du montant rendu (reglement en especes) -if ($obj_facturation->amountReturned()) { - echo (''); -} - -?> - -
    trans("Invoice"); ?>numInvoice(); ?>
    trans("TotalHT"); ?>amountWithoutTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?>
    '.$langs->trans("VAT").''.price(price2num($obj_facturation->amountVat(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
    '.$langs->trans("VAT").''.$langs->trans("NoVAT").'
    trans("TotalTTC"); ?> amountWithTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?>
    trans("PaymentMode"); ?> - getSetPaymentMode()) { - case 'ESP': - echo $langs->trans("Cash"); - $filtre = 'courant=2'; - if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { - $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; - } - break; - case 'CB': - echo $langs->trans("CreditCard"); - $filtre = 'courant=1'; - if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { - $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; - } - break; - case 'CHQ': - echo $langs->trans("Cheque"); - $filtre = 'courant=1'; - if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { - $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; - } - break; - case 'DIF': - echo $langs->trans("Reported"); - $filtre = 'courant=1 OR courant=2'; - $selected = ''; - break; - default: - $filtre = 'courant=1 OR courant=2'; - $selected = ''; - } - - ?> -
    '.$langs->trans("DateDue").''.$obj_facturation->paiementLe().'
    '.$langs->trans("Received").''.price(price2num($obj_facturation->amountCollected(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
    '.$langs->trans("Change").''.price(price2num($obj_facturation->amountReturned(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
    - -
    - -

    - trans("BankToPay")."
    "; - $form->select_comptes($selected, 'cashdeskbank', 0, $filtre); - ?> -

    -

    trans("Notes"); ?>

    - - -
    - - - -
    diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php deleted file mode 100644 index d89edfdc41a..00000000000 --- a/htdocs/cashdesk/tpl/validation2.tpl.php +++ /dev/null @@ -1,57 +0,0 @@ - - * Copyright (C) 2012 Marcos García - * - * 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 . - * - */ - -// Protection to avoid direct call of template -if (empty($langs) || !is_object($langs)) { - print "Error, template page can't be called as URL"; - exit; -} - -// Load translation files required by the page -$langs->loadLangs(array("main", "bills")); - -?> - -
    - -
    -

    trans("SellFinished"); ?>


    - - - -

    trans("ShowInvoice"); ?>

    -
    -

    trans("PrintTicket"); ?>

    - -
    -
    -
    - diff --git a/htdocs/cashdesk/validation_ticket.php b/htdocs/cashdesk/validation_ticket.php deleted file mode 100644 index 5fcf017ada1..00000000000 --- a/htdocs/cashdesk/validation_ticket.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/validation_ticket.php - * \ingroup cashdesk - * \brief validation_ticket.php - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * Actions - */ - -$obj_facturation = unserialize($_SESSION['serObjFacturation']); -unset($_SESSION['serObjFacturation']); - -$hookmanager->initHooks(array('cashdeskTplTicket')); - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation); -if (empty($reshook)) { - require 'tpl/ticket.tpl.php'; -} - - -$_SESSION['serObjFacturation'] = serialize($obj_facturation); diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php deleted file mode 100644 index 0c9758d9a29..00000000000 --- a/htdocs/cashdesk/validation_verif.php +++ /dev/null @@ -1,361 +0,0 @@ - - * Copyright (C) 2008-2009 Laurent Destailleur - * Copyright (C) 2011 Juanjo Menent - * - * 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 . - */ - -/** - * \file htdocs/cashdesk/validation_verif.php - * \ingroup cashdesk - * \brief validation_verif.php - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; -require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -$obj_facturation = unserialize($_SESSION['serObjFacturation']); - -$action = GETPOST('action', 'aZ09'); -$bankaccountid = GETPOST('cashdeskbank'); - -if (empty($user->rights->cashdesk->run)) { - accessforbidden(); -} - - -/* - * Actions - */ - -switch ($action) { - default: - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; - break; - - case 'validate_sell': - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - - $company = new Societe($db); - $company->fetch($thirdpartyid); - - $invoice = new Facture($db); - $invoice->date = dol_now(); - $invoice->type = Facture::TYPE_STANDARD; - - // To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here - // and restore values just after - $sav_FACTURE_ADDON = ''; - if (!empty($conf->global->POS_ADDON)) { - $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; - $conf->global->FACTURE_ADDON = $conf->global->POS_ADDON; - - // To force prefix only for POS with terre module - if (!empty($conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX)) { - $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX = $conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX; - } - // To force prefix only for POS with mars module - if (!empty($conf->global->POS_NUMBERING_MARS_FORCE_PREFIX)) { - $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX = $conf->global->POS_NUMBERING_MARS_FORCE_PREFIX; - } - // To force rule only for POS with mercure - //... - } - - $num = $invoice->getNextNumRef($company); - - // Restore save values - if (!empty($sav_FACTURE_ADDON)) { - $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; - } - - $obj_facturation->numInvoice($num); - - $obj_facturation->getSetPaymentMode($_POST['hdnChoix']); - - // Si paiement autre qu'en especes, montant encaisse = prix total - $mode_reglement = $obj_facturation->getSetPaymentMode(); - if ($mode_reglement != 'ESP') { - $montant = $obj_facturation->amountWithTax(); - } else { - $montant = $_POST['txtEncaisse']; - } - - if ($mode_reglement != 'DIF') { - $obj_facturation->amountCollected($montant); - - //Determination de la somme rendue - $total = $obj_facturation->amountWithTax(); - $encaisse = $obj_facturation->amountCollected(); - - $obj_facturation->amountReturned($encaisse - $total); - } else { - //$txtDatePaiement=$_POST['txtDatePaiement']; - $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); - $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); - $obj_facturation->paiementLe($txtDatePaiement); - } - - $redirection = 'affIndex.php?menutpl=validation'; - break; - - - case 'retour': - $redirection = 'affIndex.php?menutpl=facturation'; - break; - - - case 'validate_invoice': - $now = dol_now(); - - // Recuperation de la date et de l'heure - $date = dol_print_date($now, 'day'); - $heure = dol_print_date($now, 'hour'); - - $note = ''; - if (!is_object($obj_facturation)) { - dol_print_error('', 'Empty context'); - exit; - } - - switch ($obj_facturation->getSetPaymentMode()) { - case 'DIF': - $mode_reglement_id = 0; - //$cond_reglement_id = dol_getIdFromCode($db,'RECEP','cond_reglement','code','rowid') - $cond_reglement_id = 0; - break; - case 'ESP': - $mode_reglement_id = dol_getIdFromCode($db, 'LIQ', 'c_paiement', 'code', 'id', 1); - $cond_reglement_id = 0; - $note .= $langs->trans("Cash")."\n"; - $note .= $langs->trans("Received").' : '.$obj_facturation->amountCollected()." ".$conf->currency."\n"; - $note .= $langs->trans("Rendu").' : '.$obj_facturation->amountReturned()." ".$conf->currency."\n"; - $note .= "\n"; - $note .= '--------------------------------------'."\n\n"; - break; - case 'CB': - $mode_reglement_id = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1); - $cond_reglement_id = 0; - break; - case 'CHQ': - $mode_reglement_id = dol_getIdFromCode($db, 'CHQ', 'c_paiement', 'code', 'id', 1); - $cond_reglement_id = 0; - break; - } - if (empty($mode_reglement_id)) { - $mode_reglement_id = 0; // If mode_reglement_id not found - } - if (empty($cond_reglement_id)) { - $cond_reglement_id = 0; // If cond_reglement_id not found - } - $note .= GETPOST('txtaNotes', 'alphanohtml'); - dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id); - - $error = 0; - - - $db->begin(); - - $user->fetch($_SESSION['uid']); - $user->getrights(); - - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); - $societe->fetch($thirdpartyid); - - $invoice = new Facture($db); - - // Get content of cart - $tab_liste = $_SESSION['poscart']; - - // Loop on each line into cart - $tab_liste_size = count($tab_liste); - for ($i = 0; $i < $tab_liste_size; $i++) { - $tmp = getTaxesFromId($tab_liste[$i]['fk_tva']); - $vat_rate = $tmp['rate']; - $vat_npr = $tmp['npr']; - $vat_src_code = $tmp['code']; - - $invoiceline = new FactureLigne($db); - $invoiceline->fk_product = $tab_liste[$i]['fk_article']; - $invoiceline->desc = $tab_liste[$i]['label']; - $invoiceline->qty = $tab_liste[$i]['qte']; - $invoiceline->remise_percent = $tab_liste[$i]['remise_percent']; - $invoiceline->price = $tab_liste[$i]['price']; - $invoiceline->subprice = $tab_liste[$i]['price']; - - $invoiceline->tva_tx = empty($vat_rate) ? 0 : $vat_rate; // works even if vat_rate is '' - $invoiceline->info_bits = empty($vat_npr) ? 0 : $vat_npr; - $invoiceline->vat_src_code = $vat_src_code; - - $invoiceline->total_ht = $tab_liste[$i]['total_ht']; - $invoiceline->total_ttc = $tab_liste[$i]['total_ttc']; - $invoiceline->total_tva = $tab_liste[$i]['total_vat']; - $invoiceline->total_localtax1 = $tab_liste[$i]['total_localtax1']; - $invoiceline->total_localtax2 = $tab_liste[$i]['total_localtax2']; - - $invoice->lines[] = $invoiceline; - } - - $invoice->socid = $conf_fksoc; - $invoice->date_creation = $now; - $invoice->date = $now; - $invoice->date_lim_reglement = 0; - $invoice->total_ht = $obj_facturation->amountWithoutTax(); - $invoice->total_tva = $obj_facturation->amountVat(); - $invoice->total_ttc = $obj_facturation->amountWithTax(); - $invoice->note_private = $note; - $invoice->cond_reglement_id = $cond_reglement_id; - $invoice->mode_reglement_id = $mode_reglement_id; - $invoice->module_source = 'cashdesk'; - $invoice->pos_source = '0'; - //print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit; - - // Si paiement differe ... - if ($obj_facturation->getSetPaymentMode() == 'DIF') { - $resultcreate = $invoice->create($user, 0, dol_stringtotime($obj_facturation->paiementLe())); - if ($resultcreate > 0) { - $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); - if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { - $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice - } - - $resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0); - - if ($warehouseidtodecrease > 0) { - // Decrease - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); - // Loop on each line - $cpt = count($invoice->lines); - for ($i = 0; $i < $cpt; $i++) { - if ($invoice->lines[$i]->fk_product > 0) { - $mouvP = new MouvementStock($db); - $mouvP->origin = &$invoice; - // We decrease stock for product - if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) { - $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); - } else { - $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); - } - if ($result < 0) { - $error++; - } - } - } - } - } else { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; - } - - $id = $invoice->id; - } else { - $resultcreate = $invoice->create($user, 0, 0); - if ($resultcreate > 0) { - $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); - if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { - $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice - } - - $resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0); - - if ($warehouseidtodecrease > 0) { - // Decrease - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); - // Loop on each line - $cpt = count($invoice->lines); - for ($i = 0; $i < $cpt; $i++) { - if ($invoice->lines[$i]->fk_product > 0) { - $mouvP = new MouvementStock($db); - $mouvP->origin = &$invoice; - // We decrease stock for product - if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) { - $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); - } else { - $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); - } - if ($result < 0) { - setEventMessages($mouvP->error, $mouvP->errors, 'errors'); - $error++; - } - } - } - } - - $id = $invoice->id; - - // Add the payment - $payment = new Paiement($db); - $payment->datepaye = $now; - $payment->amounts[$invoice->id] = $obj_facturation->amountWithTax(); - $payment->note_public = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice(); - $payment->paiementid = $invoice->mode_reglement_id; - $payment->num_paiement = ''; - $payment->num_payment = ''; - - $paiement_id = $payment->create($user); - if ($paiement_id > 0) { - if (!$error) { - $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); - if (!$result > 0) { - $errmsg = $paiement->error; - $error++; - } - } - - if (!$error) { - if ($invoice->total_ttc == $obj_facturation->amountWithTax() - && $obj_facturation->getSetPaymentMode() != 'DIFF') { - // We set status to paid - $result = $invoice->setPaid($user); - //print 'set paid';exit; - } - } - } else { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; - } - } else { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; - } - } - - - if (!$error) { - $db->commit(); - $redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr - } else { - $db->rollback(); - $redirection = 'affIndex.php?facid='.$id.'&error=1&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr - } - break; - - // End of case: validate_invoice -} - -unset($_SESSION['serObjFacturation']); - -$_SESSION['serObjFacturation'] = serialize($obj_facturation); - -header('Location: '.$redirection); -exit; diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index bddeb9a771a..02e6892b571 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -101,9 +101,9 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('CATEGORIE_RECURSIV_ADD'); } else { if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) { - print ''.img_picto($langs->trans("Disabled"), 'off').''; + print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { - print ''.img_picto($langs->trans("Enabled"), 'on').''; + print ''.img_picto($langs->trans("Enabled"), 'on').''; } } print ''; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 141e061ac20..ec3d75dee1a 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -266,7 +266,7 @@ if ($user->rights->categorie->creer) { $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit', $parameters); + print $object->showOptionals($extrafields, 'create', $parameters); } print ''; @@ -274,7 +274,7 @@ if ($user->rights->categorie->creer) { print dol_get_fiche_end(''); print '
    '; - print ''; + print ''; print '     '; print ''; print '
    '; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 158627e274c..84300e76d98 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -103,7 +103,7 @@ class Categories extends DolibarrApi if (!is_array($cats)) { throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); } - $this->category->childs = []; + $this->category->childs = array(); foreach ($cats as $cat) { $this->category->childs[] = $this->_cleanObjectDatas($cat); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 3ddfaa4d92b..4f8c6b28d41 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; @@ -56,6 +57,8 @@ class Categorie extends CommonObject const TYPE_WAREHOUSE = 'warehouse'; const TYPE_ACTIONCOMM = 'actioncomm'; const TYPE_WEBSITE_PAGE = 'website_page'; + const TYPE_TICKET = 'ticket'; + const TYPE_KNOWLEDGEMANAGEMENT = 'knowledgemanagement'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -78,7 +81,9 @@ class Categorie extends CommonObject 'bank_line' => 8, 'warehouse' => 9, 'actioncomm' => 10, - 'website_page' => 11 + 'website_page' => 11, + 'ticket' => 12, + 'knowledgemanagement' => 13 ); /** @@ -98,7 +103,9 @@ class Categorie extends CommonObject 8 => 'bank_line', 9 => 'warehouse', 10 => 'actioncomm', - 11 => 'website_page' + 11 => 'website_page', + 12 => 'ticket', + 13 => 'knowledgemanagement' ); /** @@ -141,7 +148,9 @@ class Categorie extends CommonObject 'project' => 'Project', 'warehouse'=> 'Entrepot', 'actioncomm' => 'ActionComm', - 'website_page' => 'WebsitePage' + 'website_page' => 'WebsitePage', + 'ticket' => 'Ticket', + 'knowledgemanagement' => 'KnowledgeRecord' ); /** @@ -234,6 +243,8 @@ class Categorie extends CommonObject * @see Categorie::TYPE_WAREHOUSE * @see Categorie::TYPE_ACTIONCOMM * @see Categorie::TYPE_WEBSITE_PAGE + * @see Categorie::TYPE_TICKET + */ public $type; @@ -448,7 +459,7 @@ class Categorie extends CommonObject $sql .= ($this->socid > 0 ? $this->socid : 'null').", "; } $sql .= "'".$this->db->escape($this->visible)."', "; - $sql .= $this->db->escape($type).", "; + $sql .= ((int) $type).", "; $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').", "; $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').", "; $sql .= (int) $conf->entity.", "; @@ -606,7 +617,7 @@ class Categorie extends CommonObject if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql .= " SET fk_parent = ".((int) $this->fk_parent); - $sql .= " WHERE fk_parent = ".$this->id; + $sql .= " WHERE fk_parent = ".((int) $this->id); if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); @@ -615,19 +626,25 @@ class Categorie extends CommonObject } $arraydelete = array( - 'categorie_societe' => 'fk_categorie', - 'categorie_fournisseur' => 'fk_categorie', 'categorie_product' => 'fk_categorie', + 'categorie_fournisseur' => 'fk_categorie', + 'categorie_societe' => 'fk_categorie', 'categorie_member' => 'fk_categorie', 'categorie_contact' => 'fk_categorie', + 'categorie_user' => 'fk_categorie', + 'categorie_project' => 'fk_categorie', 'categorie_account' => 'fk_categorie', + 'categorie_website_page' => 'fk_categorie', + 'categorie_warehouse' => 'fk_categorie', + 'categorie_actioncomm' => 'fk_categorie', + 'categorie_ticket' => 'fk_categorie', 'bank_class' => 'fk_categ', 'categorie_lang' => 'fk_category', 'categorie' => 'rowid', ); foreach ($arraydelete as $key => $value) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; - $sql .= " WHERE ".$value." = ".$this->id; + $sql .= " WHERE ".$value." = ".((int) $this->id); if (!$this->db->query($sql)) { $this->errors[] = $this->db->lasterror(); dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); @@ -680,7 +697,7 @@ class Categorie extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); $sql .= " (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).")"; - $sql .= " VALUES (".$this->id.", ".$obj->id.")"; + $sql .= " VALUES (".((int) $this->id).", ".((int) $obj->id).")"; dol_syslog(get_class($this).'::add_type', LOG_DEBUG); if ($this->db->query($sql)) { @@ -717,8 +734,6 @@ class Categorie extends CommonObject } } - - // Call trigger $this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_LINK', $user); @@ -917,12 +932,11 @@ class Categorie extends CommonObject $idoftype = array_search($type, self::$MAP_ID_TO_CODE); $sql = "SELECT s.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie as s"; - $sql .= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as s, ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub"; $sql .= ' WHERE s.entity IN ('.getEntity('category').')'; $sql .= ' AND s.type='.((int) $idoftype); $sql .= ' AND s.rowid = sub.fk_categorie'; - $sql .= ' AND sub.'.$subcol_name.' = '.((int) $id); + $sql .= " AND sub.".$subcol_name." = ".((int) $id); $sql .= $this->db->order($sortfield, $sortorder); @@ -995,7 +1009,7 @@ class Categorie extends CommonObject { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql .= " WHERE fk_parent = ".$this->id; + $sql .= " WHERE fk_parent = ".((int) $this->id); $sql .= " AND entity IN (".getEntity('category').")"; $res = $this->db->query($sql); @@ -1401,7 +1415,7 @@ class Categorie extends CommonObject $parents = array(); $sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $res = $this->db->query($sql); @@ -1804,13 +1818,13 @@ class Categorie extends CommonObject if ($key == $current_lang) { if ($this->db->num_rows($result)) { // si aucune ligne dans la base $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2 .= " SET label='".$this->db->escape($this->label)."',"; - $sql2 .= " description='".$this->db->escape($this->description)."'"; - $sql2 .= " WHERE fk_category=".((int) $this->id)." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " SET label = '".$this->db->escape($this->label)."',"; + $sql2 .= " description = '".$this->db->escape($this->description)."'"; + $sql2 .= " WHERE fk_category = ".((int) $this->id)." AND lang = '".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label); - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + $sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->label)."'"; + $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["description"])."')"; } dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); if (!$this->db->query($sql2)) { @@ -1825,8 +1839,8 @@ class Categorie extends CommonObject $sql2 .= " WHERE fk_category=".((int) $this->id)." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"]); - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + $sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->multilangs["$key"]["label"])."'"; + $sql2 .= ",'".$this->db->escape($this->multilangs["$key"]["description"])."')"; } // on ne sauvegarde pas des champs vides diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 5fb1c85dd40..5c014b6206f 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -231,10 +231,10 @@ if ($object->id) { // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) { - print ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; + print ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; } if ($user->rights->categorie->creer) { - print ''; + print ''; print img_delete().''; } if ($nbbyrow) { diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index cd5d7ad8214..2bbb4b5f0a8 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -231,9 +231,9 @@ print "\n
    \n"; if ($action == '') { if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans('Add').''; + print ''.$langs->trans('Add').''; if ($cnt_trans > 0) { - print ''.$langs->trans('Update').''; + print ''.$langs->trans('Update').''; } } } @@ -274,11 +274,7 @@ if ($action == 'edit') { print '
    '; - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; } elseif ($action != 'add') { @@ -334,11 +330,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index eeca990ef28..78d01a19e19 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -142,6 +142,11 @@ if ($id > 0 && $removeelem > 0) { $tmpobject = new User($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'user'; + } elseif ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) { + require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; + $tmpobject = new Ticket($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'ticket'; } $result = $object->del_type($tmpobject, $elementtype); @@ -167,7 +172,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi if ($elemid && $action == 'addintocategory' && (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || - ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) || + ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) || + ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) || + ($type == Categorie::TYPE_MEMBER && $user->rights->projet->creer) || + ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) || + ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) || + ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) )) { if ($type == Categorie::TYPE_PRODUCT) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -181,6 +192,30 @@ if ($elemid && $action == 'addintocategory' && require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $newobject = new Societe($db); $elementtype = 'supplier'; + } elseif ($type == Categorie::TYPE_TICKET) { + require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; + $newobject = new Ticket($db); + $elementtype = 'ticket'; + } elseif ($type == Categorie::TYPE_PROJECT) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $newobject = new Project($db); + $elementtype = 'project'; + } elseif ($type == Categorie::TYPE_MEMBER) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $newobject = new Adherent($db); + $elementtype = 'member'; + } elseif ($type == Categorie::TYPE_CONTACT) { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $newobject = new Contact($db); + $elementtype = 'contact'; + } elseif ($type == Categorie::TYPE_USER) { + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $newobject = new User($db); + $elementtype = 'user'; + } elseif ($type == Categorie::TYPE_ACCOUNT) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $newobject = new User($db); + $elementtype = 'bank_account'; } $result = $newobject->fetch($elemid); @@ -189,7 +224,7 @@ if ($elemid && $action == 'addintocategory' && if ($result >= 0) { setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs'); } else { - if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -528,6 +563,7 @@ if ($type == Categorie::TYPE_PRODUCT) { } } +// List of customers if ($type == Categorie::TYPE_CUSTOMER) { $permission = $user->rights->societe->creer; @@ -601,7 +637,7 @@ if ($type == Categorie::TYPE_CUSTOMER) { } } - +// List of suppliers if ($type == Categorie::TYPE_SUPPLIER) { $permission = $user->rights->societe->creer; @@ -686,6 +722,26 @@ if ($type == Categorie::TYPE_MEMBER) { if ($prods < 0) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
    '; + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddMemberIntoCategory").'  '; + print $form->selectMembers('', 'elemid'); + print '
    '; + print '
    '; + } + print '
    '; print ''; print ''; @@ -742,6 +798,25 @@ if ($type == Categorie::TYPE_CONTACT) { if ($contacts < 0) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddContactIntoCategory").'  '; + print $form->selectContacts('', '', 'elemid'); + print '
    '; + print '
    '; + } print '
    '; print ''; print ''; @@ -760,7 +835,7 @@ if ($type == Categorie::TYPE_CONTACT) { print ''."\n"; print ''."\n"; - if (count($contacts) > 0) { + if (is_array($contacts) && count($contacts) > 0) { $i = 0; foreach ($contacts as $key => $contact) { $i++; @@ -807,6 +882,26 @@ if ($type == Categorie::TYPE_ACCOUNT) { if ($accounts < 0) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '.$langs->trans("Ref").'
    '; + print ''; + print ''; + print '
    '; + print $langs->trans("AddAccountIntoCategory").'  '; + $form->select_comptes('', 'elemid'); + print '
    '; + print '
    '; + } + print '
    '; print ''; print ''; @@ -864,6 +959,26 @@ if ($type == Categorie::TYPE_PROJECT) { if ($objects < 0) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddProjectIntoCategory").'  '; + $form->selectProjects('', 'elemid'); + print '
    '; + print '
    '; + } + print '
    '; print ''; print ''; @@ -920,6 +1035,25 @@ if ($type == Categorie::TYPE_USER) { if ($users < 0) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddProjectIntoCategory").'  '; + $form->select_users('', 'elemid'); + print '
    '; + print '
    '; + } print '
    '; print ''; print ''; @@ -1024,6 +1158,78 @@ if ($type == Categorie::TYPE_WAREHOUSE) { } } +if ($type == Categorie::TYPE_TICKET) { + $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer); + + $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($tickets < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddTicketIntoCategory").'  '; + $form->selectTickets('', 'elemid'); + print '
    '; + print '
    '; + } + + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
    '; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($tickets); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit); + + + print ''."\n"; + print ''."\n"; + + if (count($tickets) > 0) { + $i = 0; + foreach ($tickets as $ticket) { + $i++; + if ($i > $limit) break; + + print "\t".''."\n"; + print '\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; + } + } else { + print ''; + } + print "
    '.$langs->trans("Ref").'
    '; + print $ticket->getNomUrl(1); + print "'.$ticket->label."'; + if ($permission) { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
    '.$langs->trans("ThisCategoryHasNoItems").'
    \n"; + + print '
    '."\n"; + } +} // End of page llxFooter(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index bc9b77cc881..54a33417854 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -75,8 +75,13 @@ if ($complete == 'na' || $complete == -2) { $complete = -1; } -$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); -$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); +if ($fulldayevent) { + $datep = dol_mktime('00', '00', 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); + $datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); +} else { + $datep = dol_mktime($aphour, $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); + $datef = dol_mktime($p2hour, $p2min, '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); +} // Security check $socid = GETPOST('socid', 'int'); @@ -278,8 +283,20 @@ if (empty($reshook) && $action == 'add') { $object->fulldayevent = (!empty($fulldayevent) ? 1 : 0); $object->location = GETPOST("location", 'alphanohtml'); $object->label = GETPOST('label', 'alphanohtml'); - $object->fk_element = GETPOST("fk_element", 'int'); - $object->elementtype = GETPOST("elementtype", 'alpha'); + + if (GETPOST("elementtype", 'alpha')) { + $modulecodetouseforpermissioncheck = GETPOST("elementtype", 'alpha'); + + $hasPermissionOnLinkedObject = 0; + if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) { + $hasPermissionOnLinkedObject = 1; + } + if ($hasPermissionOnLinkedObject) { + $object->fk_element = GETPOST("fk_element", 'int'); + $object->elementtype = GETPOST("elementtype", 'alpha'); + } + } + if (!GETPOST('label')) { if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) { $object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs)); @@ -520,8 +537,20 @@ if (empty($reshook) && $action == 'update') { } $object->fk_project = GETPOST("projectid", 'int'); $object->note_private = trim(GETPOST("note", "restricthtml")); - $object->fk_element = GETPOST("fk_element", "int"); - $object->elementtype = GETPOST("elementtype", "alphanohtml"); + + if (GETPOST("elementtype", 'alpha')) { + $modulecodetouseforpermissioncheck = GETPOST("elementtype", 'alpha'); + + $hasPermissionOnLinkedObject = 0; + if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) { + $hasPermissionOnLinkedObject = 1; + } + if ($hasPermissionOnLinkedObject) { + $object->fk_element = GETPOST("fk_element", 'int'); + $object->elementtype = GETPOST("elementtype", 'alpha'); + } + } + if (!$datef && $percentage == 100) { $error++; $donotclearsession = 1; setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), $object->errors, 'errors'); @@ -595,10 +624,10 @@ if (empty($reshook) && $action == 'update') { $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id != ".$object->id; + $sql .= " WHERE ac.id <> ".((int) $object->id); $sql .= " AND er.resource_id IN ("; $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".$object->id; + $sql .= " WHERE element_id = ".((int) $object->id); $sql .= " AND element_type = '".$db->escape($object->element)."'"; $sql .= " AND busy = 1"; $sql .= ")"; @@ -774,10 +803,10 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id != ".$object->id; + $sql .= " WHERE ac.id <> ".((int) $object->id); $sql .= " AND er.resource_id IN ("; $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".$object->id; + $sql .= " WHERE element_id = ".((int) $object->id); $sql .= " AND element_type = '".$db->escape($object->element)."'"; $sql .= " AND busy = 1"; $sql .= ")"; @@ -1189,9 +1218,9 @@ if ($action == 'create') { print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print $formproject->select_projects((empty($societe->id) ? '' : $societe->id), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); - print ' '; + print ' '; print ''; $urloption = '?action=create&donotclearsession=1'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; @@ -1218,7 +1247,7 @@ if ($action == 'create') { if (!empty($projectid)) { $projectsListId = $projectid; } - $tid = GETPOST("projecttaskid") ? GETPOST("projecttaskid") : ''; + $tid = GETPOSTISSET("projecttaskid") ? GETPOST("projecttaskid", 'int') : (GETPOSTISSET("taskid") ? GETPOST("taskid", 'int') : ''); $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500', $projectsListId); print ''; } @@ -1227,14 +1256,26 @@ if ($action == 'create') { if (!empty($origin) && !empty($originid)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $hasPermissionOnLinkedObject = 0; + if ($user->hasRight($origin, 'read')) { + $hasPermissionOnLinkedObject = 1; + } + //var_dump('origin='.$origin.' originid='.$originid.' $hasPermissionOnLinkedObject='.$hasPermissionOnLinkedObject); + if (! in_array($origin, array('societe', 'project', 'task', 'user'))) { - // We do not use link for object that already contains a hard coded + // We do not use link for object that already contains a hard coded field to make links with agenda events print ''.$langs->trans("LinkedObject").''; - print ''.dolGetElementUrl($originid, $origin, 1).''; - print ''; - print ''; - print ''; - print ''; + print ''; + if ($hasPermissionOnLinkedObject) { + print dolGetElementUrl($originid, $origin, 1); + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + } + print ''; } } @@ -1262,7 +1303,7 @@ if ($action == 'create') { $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit', $parameters); + print $object->showOptionals($extrafields, 'create', $parameters); } print ''; @@ -1325,15 +1366,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - if (empty($backtopage)) { - print ''; - } else { - print ''; - } - print '
    '; + print $form->buttonsSaveCancel("Add"); print ""; } @@ -1660,7 +1693,7 @@ if ($id > 0) { print img_picto('', 'project', 'class="paddingrightonly"'); $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500'); if ($numprojet == 0) { - print '   '; + print '   '; } print ''; } @@ -1812,11 +1845,7 @@ if ($id > 0) { print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print $form->buttonsSaveCancel(); print ''; } else { @@ -1863,7 +1892,7 @@ if ($id > 0) { if ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); @@ -1871,7 +1900,7 @@ if ($id > 0) { $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= ''; } else { $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); @@ -2144,7 +2173,7 @@ if ($id > 0) { if ($action != 'edit') { if ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - print ''; + print ''; } else { print ''; } @@ -2185,10 +2214,10 @@ if ($id > 0) { print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); - print '
    '; + print '
    '; - print '
    '; + print ''; } } } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5aabfc22bd1..3e2520f43da 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -261,7 +261,7 @@ class ActionComm extends CommonObject /** * @var int socpeople id linked to action */ - public $contactid; + public $contact_id; /** * @var Societe|null Company linked to action (optional) @@ -273,7 +273,7 @@ class ActionComm extends CommonObject /** * @var Contact|null Contact linked to action (optional) * @deprecated - * @see $contactid + * @see $contact_id */ public $contact; @@ -542,18 +542,18 @@ class ActionComm extends CommonObject $sql .= (isset($this->type_id) ? $this->type_id : "null").","; $sql .= ($code ? ("'".$this->db->escape($code)."'") : "null").", "; $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").", "; - $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; - $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; + $sql .= ((isset($this->socid) && $this->socid > 0) ? ((int) $this->socid) : "null").", "; + $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? ((int) $this->fk_project) : "null").", "; $sql .= " '".$this->db->escape($this->note_private)."', "; - $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned + $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? ((int) $this->contact_id) : "null").", "; // deprecated, use ->socpeopleassigned $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", "; $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; $sql .= "'".$this->db->escape($this->transparency)."', "; - $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; + $sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) : "null").", "; $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; - $sql .= $conf->entity.","; + $sql .= ((int) $conf->entity).","; $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; // Fields emails $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; @@ -596,7 +596,7 @@ class ActionComm extends CommonObject } $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; + $sql .= " VALUES(".((int) $this->id).", 'user', ".((int) $val['id']).", ".(empty($val['mandatory']) ? '0' : ((int) $val['mandatory'])).", ".(empty($val['transparency']) ? '0' : ((int) $val['transparency'])).", ".(empty($val['answer_status']) ? '0' : ((int) $val['answer_status'])).")"; $resql = $this->db->query($sql); if (!$resql) { @@ -621,7 +621,7 @@ class ActionComm extends CommonObject } $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $id).", 0, 0, 0)"; $resql = $this->db->query($sql); if (!$resql) { @@ -865,6 +865,7 @@ class ActionComm extends CommonObject $this->fetchResources(); } } + $this->db->free($resql); } else { $this->error = $this->db->lasterror(); @@ -984,7 +985,7 @@ class ActionComm extends CommonObject // remove categorie association if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_actioncomm"; - $sql .= " WHERE fk_actioncomm=".$this->id; + $sql .= " WHERE fk_actioncomm=".((int) $this->id); $res = $this->db->query($sql); if (!$res) { @@ -996,7 +997,7 @@ class ActionComm extends CommonObject // remove actioncomm_resources if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql .= " WHERE fk_actioncomm=".$this->id; + $sql .= " WHERE fk_actioncomm=".((int) $this->id); $res = $this->db->query($sql); if (!$res) { @@ -1028,7 +1029,7 @@ class ActionComm extends CommonObject // remove actioncomm if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; - $sql .= " WHERE id=".$this->id; + $sql .= " WHERE id=".((int) $this->id); $res = $this->db->query($sql); if (!$res) { @@ -1181,7 +1182,7 @@ class ActionComm extends CommonObject if (!empty($already_inserted[$val['id']])) continue; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; + $sql .= " VALUES(".((int) $this->id).", 'user', ".((int) $val['id']).", ".(empty($val['mandatory']) ? '0' : ((int) $val['mandatory'])).", ".(empty($val['transparency']) ? '0' : ((int) $val['transparency'])).", ".(empty($val['answer_status']) ? '0' : ((int) $val['answer_status'])).")"; $resql = $this->db->query($sql); if (!$resql) { @@ -1204,7 +1205,7 @@ class ActionComm extends CommonObject if (!empty($already_inserted[$val['id']])) continue; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $id).", 0, 0, 0)"; $resql = $this->db->query($sql); if (!$resql) { @@ -1245,7 +1246,6 @@ class ActionComm extends CommonObject * Load all objects with filters. * @todo WARNING: This make a fetch on all records instead of making one request with a join. * - * @param DoliDb $db Not used * @param int $socid Filter by thirdparty * @param int $fk_element Id of element action is linked to * @param string $elementtype Type of element action is linked to @@ -1255,7 +1255,7 @@ class ActionComm extends CommonObject * @param string $limit Limit number of answers * @return array|string Error string if KO, array with actions if OK */ - public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) + public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) { global $conf, $langs; @@ -1277,33 +1277,33 @@ class ActionComm extends CommonObject $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; $sql .= " element_type = 'socpeople' AND fk_element = ".((int) $fk_element).')'; } else { - $sql .= " AND a.fk_element = ".((int) $fk_element)." AND a.elementtype = '".$db->escape($elementtype)."'"; + $sql .= " AND a.fk_element = ".((int) $fk_element)." AND a.elementtype = '".$this->db->escape($elementtype)."'"; } } if (!empty($filter)) { $sql .= $filter; } if ($sortorder && $sortfield) { - $sql .= $db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } - $sql .= $db->plimit($limit, 0); + $sql .= $this->db->plimit($limit, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num) { for ($i = 0; $i < $num; $i++) { - $obj = $db->fetch_object($resql); - $actioncommstatic = new ActionComm($db); + $obj = $this->db->fetch_object($resql); + $actioncommstatic = new ActionComm($this->db); $actioncommstatic->fetch($obj->id); $resarray[$i] = $actioncommstatic; } } - $db->free($resql); + $this->db->free($resql); return $resarray; } else { - return $db->lasterror(); + return $this->db->lasterror(); } } @@ -1327,10 +1327,10 @@ class ActionComm extends CommonObject $sql = "SELECT count(a.id) as nb"; } $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; } - if (!$user->rights->agenda->allactions->read) { + if (empty($user->rights->agenda->allactions->read)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".((int) $user->id); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; @@ -1339,13 +1339,13 @@ class ActionComm extends CommonObject $sql .= " AND a.percent >= 0 AND a.percent < 100"; } $sql .= " AND a.entity IN (".getEntity('agenda').")"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; } if ($user->socid) { $sql .= " AND a.fk_soc = ".((int) $user->socid); } - if (!$user->rights->agenda->allactions->read) { + if (empty($user->rights->agenda->allactions->read)) { $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id); $sql .= " OR ar.fk_element = ".((int) $user->id); $sql .= ")"; @@ -1465,18 +1465,18 @@ class ActionComm extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->trans('StatusNotApplicable'); + $labelStatus = $langs->transnoentitiesnoconv('StatusNotApplicable'); if ($percent == -1 && !$hidenastatus) { - $labelStatus = $langs->trans('StatusNotApplicable'); + $labelStatus = $langs->transnoentitiesnoconv('StatusNotApplicable'); } elseif ($percent == 0) { - $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; + $labelStatus = $langs->transnoentitiesnoconv('StatusActionToDo').' (0%)'; } elseif ($percent > 0 && $percent < 100) { - $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + $labelStatus = $langs->transnoentitiesnoconv('StatusActionInProcess').' ('.$percent.'%)'; } elseif ($percent >= 100) { - $labelStatus = $langs->trans('StatusActionDone').' (100%)'; + $labelStatus = $langs->transnoentitiesnoconv('StatusActionDone').' (100%)'; } - $labelStatusShort = $langs->trans('StatusNotApplicable'); + $labelStatusShort = $langs->transnoentitiesnoconv('StatusNotApplicable'); if ($percent == -1 && !$hidenastatus) { $labelStatusShort = $langs->trans('NA'); } elseif ($percent == 0) { diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index e675c93d472..aa693d2e41f 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -228,18 +228,18 @@ class ActionCommReminder extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->trans('ToDo'); + $labelStatus = $langs->transnoentitiesnoconv('ToDo'); if ($status == 1) { - $labelStatus = $langs->trans('Done'); + $labelStatus = $langs->transnoentitiesnoconv('Done'); } elseif ($status == -1) { - $labelStatus = $langs->trans('Error'); + $labelStatus = $langs->transnoentitiesnoconv('Error'); } - $labelStatusShort = $langs->trans('ToDo'); + $labelStatusShort = $langs->transnoentitiesnoconv('ToDo'); if ($status == 1) { - $labelStatus = $langs->trans('Done'); + $labelStatus = $langs->transnoentitiesnoconv('Done'); } elseif ($status == -1) { - $labelStatus = $langs->trans('Error'); + $labelStatus = $langs->transnoentitiesnoconv('Error'); } $statusType = 'status5'; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index eb1ac59cfe0..4c4d44c3a6e 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -108,6 +108,8 @@ $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); +$now = dol_now(); +$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; if ($object->id > 0) { $result1 = $object->fetch($id); @@ -135,9 +137,6 @@ if ($object->id > 0) { $head = actions_prepare_head($object); - $now = dol_now(); - $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; - print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9b9525925c5..5f7349fab3c 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -59,6 +59,8 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; } +$newparam = ''; + $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -84,13 +86,13 @@ if ($socid < 0) { } $canedit = 1; -if (!$user->rights->agenda->myactions->read) { +if (empty($user->rights->agenda->myactions->read)) { accessforbidden(); } -if (!$user->rights->agenda->allactions->read) { +if (empty($user->rights->agenda->allactions->read)) { $canedit = 0; } -if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me +if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } @@ -263,6 +265,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) { $name = 'AGENDA_EXT_NAME'.$i; $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; $color = 'AGENDA_EXT_COLOR'.$i; + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; if (!empty($conf->global->$source) && !empty($conf->global->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' @@ -271,6 +274,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) { 'name'=>$conf->global->$name, 'offsettz' => (!empty($conf->global->$offsettz) ? $conf->global->$offsettz : 0), 'color'=>$conf->global->$color, + 'default'=>$conf->global->$default, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0) ); } @@ -286,6 +290,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; if (!empty($user->conf->$source) && !empty($user->conf->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' @@ -294,6 +299,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { 'name'=>$user->conf->$name, 'offsettz' => (!empty($user->conf->$offsettz) ? $user->conf->$offsettz : 0), 'color'=>$user->conf->$color, + 'default'=>$user->conf->$default, 'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0) ); } @@ -446,7 +452,7 @@ if ($action == 'show_day') { } $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -//$nav .= ' '; +//$nav .= ' '; $nav .= ''; // Must be after the nav definition @@ -484,7 +490,7 @@ print ''; $viewmode = ''; $viewmode .= ''; //$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="pictoactionview block"'); +$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="imgforviewmode pictoactionview block"'); //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewList").''; @@ -525,6 +531,7 @@ $viewmode .= ''; // To add a space before t $newcardbutton = ''; +$newparam = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton = dol_getdate(dol_now(), true); @@ -573,6 +580,15 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on if (is_array($showextcals) && count($showextcals) > 0) { $s .= ''; + $stringtoshow .= '
    '; // hideobject is to start hidden + $stringtoshow .= '
    '; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
    '; + $stringtoshow .= '
    '; + $stringtoshow .= $px2->show(); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); + } else { + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover left"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 5ecc26c3f90..3d8cb88938d 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -98,7 +98,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($user->socid) { $socid = $user->socid; } - if (!$user->rights->societe->client->voir || $socid) { + if (empty($user->rights->societe->client->voir) || $socid) { $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } diff --git a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php index baa822dcf29..83acae25b45 100644 --- a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php +++ b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php @@ -65,6 +65,8 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes public function loadBox($max = 5) { global $conf, $user, $langs; + $dataseries = array(); + $graphtoshow = ""; $badgeStatus0 = '#cbd3d3'; // draft $badgeStatus1 = '#bc9526'; // validated @@ -85,7 +87,7 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes $param_day = 'DOLUSERCOOKIE_ticket_last_days'; - if ($_POST[$param_day]) { + if (!empty($_POST[$param_day])) { if ($_POST[$param_day] >= 15) { $days = 14; } else { @@ -116,7 +118,6 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - $dataseries = array(); while ($i < $num) { $objp = $this->db->fetch_object($resql); while ($minimumdatecformated < $objp->datec) { diff --git a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php index a4bf2d6990f..435cc76451e 100644 --- a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php +++ b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php @@ -2,7 +2,7 @@ /* Module descriptor for ticket system * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * * 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 @@ -19,7 +19,7 @@ */ /** - * \file core/boxes/box_nb_ticket_last_x_days.php + * \file htdocs/core/boxes/box_graph_new_vs_close_ticket.php * \ingroup ticket * \brief This box shows the number of new daily tickets the last X days */ @@ -98,10 +98,10 @@ class box_graph_new_vs_close_ticket extends ModeleBoxes $num = $this->db->num_rows($resql); if ($num > 0) { $objp = $this->db->fetch_object($resql); - $data[] = array($langs->trans('TicketCreatedToday'), $objp->nb); + $data[] = array($langs->transnoentitiesnoconv('TicketCreatedToday'), $objp->nb); $totalnb += $objp->nb; } else { - $data[] = array($langs->trans('TicketCreatedToday'), 0); + $data[] = array($langs->transnoentitiesnoconv('TicketCreatedToday'), 0); } } else { dol_print_error($this->db); @@ -116,10 +116,10 @@ class box_graph_new_vs_close_ticket extends ModeleBoxes $num = $this->db->num_rows($resql); if ($num > 0) { $objp = $this->db->fetch_object($resql); - $data[] = array($langs->trans('TicketClosedToday'), $objp->nb); + $data[] = array($langs->transnoentitiesnoconv('TicketClosedToday'), $objp->nb); $totalnb += $objp->nb; } else { - $data[] = array($langs->trans('TicketClosedToday'), 0); + $data[] = array($langs->transnoentitiesnoconv('TicketClosedToday'), 0); } } else { dol_print_error($this->db); diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 48f0bd67ec3..0fd27c377d5 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -99,7 +99,7 @@ class box_graph_orders_permonth extends ModeleBoxes if ($user->socid) { $socid = $user->socid; } - if (!$user->rights->societe->client->voir || $socid) { + if (empty($user->rights->societe->client->voir) || $socid) { $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index a394834cd97..be58b1e983c 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -98,7 +98,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if ($user->socid) { $socid = $user->socid; } - if (!$user->rights->societe->client->voir || $socid) { + if (empty($user->rights->societe->client->voir) || $socid) { $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 8a95761ea08..03899fb922f 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -101,7 +101,7 @@ class box_graph_propales_permonth extends ModeleBoxes if ($user->socid) { $socid = $user->socid; } - if (!$user->rights->societe->client->voir || $socid) { + if (empty($user->rights->societe->client->voir) || $socid) { $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 13cd0c40c86..5e69a49e88e 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -2,7 +2,7 @@ /* Module descriptor for ticket system * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * * 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 @@ -19,7 +19,7 @@ */ /** - * \file core/boxes/box_ticket_by_severity.php + * \file htdocs/core/boxes/box_graph_ticket_by_severity.php * \ingroup ticket * \brief This box shows open tickets by severity */ diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 57e54594255..300a13803c5 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -96,7 +96,7 @@ class box_last_modified_ticket extends ModeleBoxes $sql .= " WHERE t.entity IN (".getEntity('ticket').')'; // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id); + //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id); if ($user->socid) { $sql .= " AND t.fk_soc = ".((int) $user->socid); } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 39086464f73..25cb353b268 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -95,7 +95,7 @@ class box_last_ticket extends ModeleBoxes $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; $sql .= " WHERE t.entity IN (".getEntity('ticket').")"; // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); if ($user->socid) { $sql .= " AND t.fk_soc= ".((int) $user->socid); } diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 5b95b58d29d..0a5e4548e3f 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -68,7 +68,7 @@ class box_members_by_type extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !($user->rights->adherent->lire); + $this->hidden = !(!empty($conf->adherent->enabled) && $user->rights->adherent->lire); } /** diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index 9de6a3af12f..cf70bcafcb1 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -67,7 +67,7 @@ class box_members_last_modified extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !($user->rights->adherent->lire); + $this->hidden = !(!empty($conf->adherent->enabled) && $user->rights->adherent->lire); } /** diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 3cea44c2dc3..949edd567f3 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -67,7 +67,7 @@ class box_members_last_subscriptions extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !($user->rights->adherent->lire); + $this->hidden = !(!empty($conf->adherent->enabled) && $user->rights->adherent->lire); } /** diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index be835511c6b..fe64f37c805 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -67,7 +67,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !($user->rights->adherent->lire); + $this->hidden = !(!empty($conf->adherent->enabled) && $user->rights->adherent->lire); } /** diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 18a19da93dc..6436fb8e34e 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -86,12 +86,15 @@ class box_mos extends ModeleBoxes if ($user->rights->mrp->read) { $sql = "SELECT p.ref as product_ref"; + $sql .= ", p.rowid as productid"; + $sql .= ", p.tosell"; + $sql .= ", p.tobuy"; + $sql .= ", p.tobatch"; $sql .= ", c.rowid"; $sql .= ", c.date_creation"; $sql .= ", c.tms"; $sql .= ", c.ref"; $sql .= ", c.status"; - //$sql.= ", c.fk_user_valid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; $sql .= " WHERE c.fk_product = p.rowid"; @@ -110,9 +113,12 @@ class box_mos extends ModeleBoxes $datem = $this->db->jdate($objp->tms); $mostatic->id = $objp->rowid; $mostatic->ref = $objp->ref; - $mostatic->id = $objp->socid; $mostatic->status = $objp->status; + $productstatic->id = $objp->productid; $productstatic->ref = $objp->product_ref; + $productstatic->status = $objp->tosell; + $productstatic->status_buy = $objp->tobuy; + $productstatic->status_batch = $objp->tobatch; $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall"', diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index dde3b685d25..d039881445e 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -122,8 +122,8 @@ class box_produits extends ModeleBoxes if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sqld = "SELECT label"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld .= " WHERE fk_product=".$objp->rowid; - $sqld .= " AND lang='".$this->db->escape($langs->getDefaultLang())."'"; + $sqld .= " WHERE fk_product = ".((int) $objp->rowid); + $sqld .= " AND lang = '".$this->db->escape($langs->getDefaultLang())."'"; $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index d7ae1566a44..5e7ec72d0e1 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -129,8 +129,8 @@ class box_produits_alerte_stock extends ModeleBoxes if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sqld = "SELECT label"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld .= " WHERE fk_product=".$objp->rowid; - $sqld .= " AND lang='".$this->db->escape($langs->getDefaultLang())."'"; + $sqld .= " WHERE fk_product = ".((int) $objp->rowid); + $sqld .= " AND lang = '".$this->db->escape($langs->getDefaultLang())."'"; $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 6599116a980..51d313b7254 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -90,12 +90,12 @@ class box_propales extends ModeleBoxes $sql .= ", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 06d42e34b18..a46713a3206 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -93,12 +93,12 @@ class box_prospect extends ModeleBoxes $sql .= ", s.fk_stcomm"; $sql .= ", s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (2, 3)"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 320932a0c6f..c72a378a1a2 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -95,7 +95,7 @@ class box_services_contracts extends ModeleBoxes $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= ")"; diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 95086cdf2a3..4353fb7eb02 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -86,16 +86,16 @@ class box_services_expired extends ModeleBoxes $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; $sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; if ($user->socid) { - $sql .= ' AND c.fk_soc = '.$user->socid; + $sql .= ' AND c.fk_soc = '.((int) $user->socid); } - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 2b6adfe3bdc..d0ddf1f8dcb 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -101,7 +101,7 @@ class box_shipments extends ModeleBoxes $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; } $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; @@ -111,7 +111,7 @@ class box_shipments extends ModeleBoxes if ($user->socid > 0) { $sql.= " AND s.rowid = ".((int) $user->socid); } - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND sc.fk_user = ".((int) $user->id); } else { $sql .= " ORDER BY e.date_delivery, e.ref DESC "; diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index b3451d9b6c3..2cc34a9255b 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -92,12 +92,12 @@ class box_supplier_orders extends ModeleBoxes $sql .= ", c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 8125a848fd0..f9d2de4b7fc 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -92,13 +92,14 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $sql .= ", c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND c.date_livraison IS NOT NULL"; $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { @@ -161,7 +162,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day', 'tzuserrel').'', + 'text' => $delayIcon.' '.($delivery_date ? dol_print_date($delivery_date, 'day', 'tzuserrel') : '').'', 'asis' => 1 ); diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 9b7cbfc2fe6..0c349ad3e4c 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -122,7 +122,7 @@ class box_task extends ModeleBoxes $boxcontent .= ''."\n"; $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); $boxcontent .= $form->selectArray($cookie_name, $selectArray, $filterValue); - $boxcontent .= ''; + $boxcontent .= ''; $boxcontent .= ''."\n"; $boxcontent .= ''."\n"; if (!empty($conf->use_javascript_ajax)) { diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index f1fb55878aa..3f2b2cdc221 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -112,11 +112,11 @@ class box_validated_projects extends ModeleBoxes $sql .= " COUNT(DISTINCT t.rowid) as tasknumber"; $sql .= " FROM ".MAIN_DB_PREFIX."projet AS p"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; - // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. + // TODO Replace -1, -2, -3 with ID used for type of contact project_task into llx_c_type_contact. Once done, we can switch widget as stable. $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; $sql .= " WHERE p.fk_statut = 1"; // Only open projects if ($projectsListId) { - $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed + $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project are allowed } $sql .= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user = ".((int) $user->id).")"; $sql .= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo"; @@ -157,7 +157,7 @@ class box_validated_projects extends ModeleBoxes ); if ($objp->fk_soc > 0) { - $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; + $sql = "SELECT rowid, nom as name FROM ".MAIN_DB_PREFIX."societe WHERE rowid = ".((int) $objp->fk_soc); $resql = $this->db->query($sql); //$socstatic = new Societe($this->db); $obj2 = $this->db->fetch_object($resql); @@ -165,7 +165,7 @@ class box_validated_projects extends ModeleBoxes 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', 'text' => $obj2->name, 'asis' => 1, - 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.urlencode($obj2->rowid) ); } else { $this->info_box_contents[$i][] = array( diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 7184d7846b0..c2dd055522e 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -128,7 +128,7 @@ class Comment extends CommonObject $sql .= ", '".(isset($this->fk_element) ? $this->fk_element : "null")."'"; $sql .= ", '".$this->db->escape($this->element_type)."'"; $sql .= ", '".(isset($this->fk_user_author) ? $this->fk_user_author : "null")."'"; - $sql .= ", ".$user->id.""; + $sql .= ", ".((int) $user->id); $sql .= ", ".(!empty($this->entity) ? $this->entity : '1'); $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ")"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 641c2f80902..7183605ae10 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -220,6 +220,7 @@ abstract class CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value + * For example {company_name}, {company_name_alias} * * @param Societe $object Object * @param Translate $outputlangs Language object for output @@ -1204,11 +1205,12 @@ abstract class CommonDocGenerator * get extrafield content for pdf writeHtmlCell compatibility * usage for PDF line columns and object note block * - * @param object $object common object - * @param string $extrafieldKey the extrafield key + * @param object $object Common object + * @param string $extrafieldKey The extrafield key + * @param Translate $outputlangs The output langs (if value is __(XXX)__ we use it to translate it). * @return string */ - public function getExtrafieldContent($object, $extrafieldKey) + public function getExtrafieldContent($object, $extrafieldKey, $outputlangs = null) { global $hookmanager; @@ -1344,7 +1346,7 @@ abstract class CommonDocGenerator $field = new stdClass(); $field->rank = intval($extrafields->attributes[$object->table_element]['pos'][$key]); - $field->content = $this->getExtrafieldContent($object, $key); + $field->content = $this->getExtrafieldContent($object, $key, $outputlangs); $field->label = $outputlangs->transnoentities($label); $field->type = $extrafields->attributes[$object->table_element]['type'][$key]; diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index 25745bb4c5c..d0485acc5a9 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -60,7 +60,7 @@ trait CommonIncoterm $this->label_incoterms = ''; if (!empty($this->fk_incoterms)) { - $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms; $result = $this->db->query($sql); if ($result) { $res = $this->db->fetch_object($result); @@ -80,7 +80,7 @@ trait CommonIncoterm */ public function getIncotermsForPDF() { - $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -107,16 +107,16 @@ trait CommonIncoterm { if ($this->id && $this->table_element) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null"); + $sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? ((int) $id_incoterm) : "null"); $sql .= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->fk_incoterms = $id_incoterm; $this->location_incoterms = $location; - $sql = 'SELECT libelle as label_incotermsFROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = "SELECT libelle as label_incoterms FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms; $res = $this->db->query($sql); if ($res) { $obj = $this->db->fetch_object($res); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 605ffec63bd..3b98d3f3356 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -132,7 +132,7 @@ abstract class CommonInvoice extends CommonObject $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql .= " WHERE ".$field." = ".((int) $this->id); dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); $resql = $this->db->query($sql); @@ -226,8 +226,8 @@ abstract class CommonInvoice extends CommonObject $idarray = array(); $sql = 'SELECT rowid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' WHERE fk_facture_source = '.$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE fk_facture_source = ".((int) $this->id); $sql .= ' AND type = 2'; $resql = $this->db->query($sql); if ($resql) { @@ -253,8 +253,8 @@ abstract class CommonInvoice extends CommonObject public function getIdReplacingInvoice($option = '') { $sql = 'SELECT rowid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' WHERE fk_facture_source = '.$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE fk_facture_source = ".((int) $this->id); $sql .= ' AND type < 2'; if ($option == 'validated') { $sql .= ' AND fk_statut = 1'; @@ -306,11 +306,10 @@ abstract class CommonInvoice extends CommonObject $sharedentity = 'facture_fourn'; } - $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; - $sql .= ' WHERE pf.'.$field.' = '.$this->id; - //$sql.= ' WHERE pf.'.$field.' = 1'; - $sql .= ' AND pf.'.$field2.' = p.rowid'; + $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3; + $sql .= " FROM ".MAIN_DB_PREFIX.$table." as pf, ".MAIN_DB_PREFIX.$table2." as p, ".MAIN_DB_PREFIX."c_paiement as t"; + $sql .= " WHERE pf.".$field." = ".((int) $this->id); + $sql .= " AND pf.".$field2." = p.rowid"; $sql .= ' AND p.fk_paiement = t.id'; $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; if ($filtertype) { @@ -336,14 +335,14 @@ abstract class CommonInvoice extends CommonObject //look for credit notes and discounts and deposits $sql = ''; if ($this->element == 'facture' || $this->element == 'invoice') { - $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type"; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $this->id); $sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) } elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { - $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type"; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $this->id); $sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) } @@ -700,9 +699,9 @@ abstract class CommonInvoice extends CommonObject $sql = 'SELECT count(*)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; if ($type == 'bank-transfer') { - $sql .= ' WHERE fk_facture_fourn = '.$this->id; + $sql .= ' WHERE fk_facture_fourn = '.((int) $this->id); } else { - $sql .= ' WHERE fk_facture = '.$this->id; + $sql .= ' WHERE fk_facture = '.((int) $this->id); } $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments $sql .= ' AND traite = 0'; @@ -735,16 +734,16 @@ abstract class CommonInvoice extends CommonObject $sql .= 'fk_facture, '; } $sql .= ' amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib, sourcetype, entity)'; - $sql .= ' VALUES ('.$this->id; - $sql .= ",'".price2num($amount)."'"; - $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",".$fuser->id; - $sql .= ",'".$this->db->escape($bac->code_banque)."'"; - $sql .= ",'".$this->db->escape($bac->code_guichet)."'"; - $sql .= ",'".$this->db->escape($bac->number)."'"; - $sql .= ",'".$this->db->escape($bac->cle_rib)."'"; - $sql .= ",'".$this->db->escape($sourcetype)."'"; - $sql .= ",".$conf->entity; + $sql .= " VALUES (".((int) $this->id); + $sql .= ", ".((float) price2num($amount)); + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".((int) $fuser->id); + $sql .= ", '".$this->db->escape($bac->code_banque)."'"; + $sql .= ", '".$this->db->escape($bac->code_guichet)."'"; + $sql .= ", '".$this->db->escape($bac->number)."'"; + $sql .= ", '".$this->db->escape($bac->cle_rib)."'"; + $sql .= ", '".$this->db->escape($sourcetype)."'"; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d53b8829686..408e32626d0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -73,6 +73,11 @@ abstract class CommonObject */ public $errors = array(); + /** + * @var array To store error results of ->validateField() + */ + public $validateFieldsErrors = array(); + /** * @var string ID to identify managed object */ @@ -123,6 +128,10 @@ abstract class CommonObject */ protected $table_ref_field = ''; + /** + * @var integer 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + */ + public $restrictiononfksoc = 0; // Following vars are used by some objects only. We keep this property here in CommonObject to be able to provide common method using them. @@ -1215,7 +1224,7 @@ abstract class CommonObject $listId = implode(",", $temp); $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; - $sql .= " WHERE element_id = ".$this->id; + $sql .= " WHERE element_id = ".((int) $this->id); if ($listId) { $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")"; } @@ -1263,9 +1272,9 @@ abstract class CommonObject if ($source == 'external' || $source == 'thirdparty') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; } - $sql .= " WHERE ec.element_id =".((int) $this->id); + $sql .= " WHERE ec.element_id = ".((int) $this->id); $sql .= " AND ec.fk_c_type_contact=tc.rowid"; - $sql .= " AND tc.element='".$this->db->escape($this->element)."'"; + $sql .= " AND tc.element = '".$this->db->escape($this->element)."'"; if ($code) { $sql .= " AND tc.code = '".$this->db->escape($code)."'"; } @@ -1662,7 +1671,7 @@ abstract class CommonObject return 0; } - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE '.$this->table_ref_field.' LIKE "'.$this->db->escape($ref).'" LIMIT 1'; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."' LIMIT 1"; $query = $this->db->query($sql); @@ -1692,7 +1701,7 @@ abstract class CommonObject $idtype = $this->barcode_type; if (empty($idtype) && $idtype != '0') { // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined - if ($this->element == 'product') { + if ($this->element == 'product' && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; } elseif ($this->element == 'societe') { $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; @@ -1944,9 +1953,9 @@ abstract class CommonObject if ($fk_user_field) { if (!empty($fuser) && is_object($fuser)) { - $sql .= ", ".$fk_user_field." = ".$fuser->id; + $sql .= ", ".$fk_user_field." = ".((int) $fuser->id); } elseif (empty($fuser) || $fuser != 'none') { - $sql .= ", ".$fk_user_field." = ".$user->id; + $sql .= ", ".$fk_user_field." = ".((int) $user->id); } } @@ -2039,19 +2048,19 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid - } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { + } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid } - if ($restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { + if ($restrictiononfksoc && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; } $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) - if ($restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { + if ($restrictiononfksoc == 1 && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND sc.fk_user = ".((int) $user->id); } - if ($restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { + if ($restrictiononfksoc == 2 && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND (sc.fk_user = ".((int) $user->id).' OR te.fk_soc IS NULL)'; } if (!empty($filter)) { @@ -2062,8 +2071,8 @@ abstract class CommonObject } if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); - $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { + $sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { @@ -2083,13 +2092,13 @@ abstract class CommonObject $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; } if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') { - $sql .= ' AND te.fk_soc = '.$socid; + $sql .= ' AND te.fk_soc = '.((int) $socid); } if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') { - $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; + $sql .= ' AND (te.fk_soc = '.((int) $socid).' OR te.fk_soc IS NULL)'; } if ($restrictiononfksoc && $socid && $this->element == 'societe') { - $sql .= ' AND te.rowid = '.$socid; + $sql .= ' AND te.rowid = '.((int) $socid); } //print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."
    "; @@ -2109,19 +2118,19 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid - } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { + } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid } - if ($restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { + if ($restrictiononfksoc && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; } $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) - if ($restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { + if ($restrictiononfksoc == 1 && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND sc.fk_user = ".((int) $user->id); } - if ($restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { + if ($restrictiononfksoc == 2 && empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND (sc.fk_user = ".((int) $user->id).' OR te.fk_soc IS NULL)'; } if (!empty($filter)) { @@ -2132,8 +2141,8 @@ abstract class CommonObject } if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); - $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { + $sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { @@ -2153,13 +2162,13 @@ abstract class CommonObject $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; } if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') { - $sql .= ' AND te.fk_soc = '.$socid; + $sql .= ' AND te.fk_soc = '.((int) $socid); } if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') { - $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; + $sql .= ' AND (te.fk_soc = '.((int) $socid).' OR te.fk_soc IS NULL)'; } if ($restrictiononfksoc && $socid && $this->element == 'societe') { - $sql .= ' AND te.rowid = '.$socid; + $sql .= ' AND te.rowid = '.((int) $socid); } //print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."
    "; // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null @@ -2214,19 +2223,19 @@ abstract class CommonObject return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; if (!empty($this->fields['fk_project'])) { // Common case if ($projectid) { - $sql .= ' SET fk_project = '.((int) $projectid); + $sql .= " SET fk_project = ".((int) $projectid); } else { - $sql .= ' SET fk_project = NULL'; + $sql .= " SET fk_project = NULL"; } $sql .= ' WHERE rowid = '.((int) $this->id); } elseif ($this->table_element == 'actioncomm') { // Special case for actioncomm if ($projectid) { - $sql .= ' SET fk_project = '.((int) $projectid); + $sql .= " SET fk_project = ".((int) $projectid); } else { - $sql .= ' SET fk_project = NULL'; + $sql .= " SET fk_project = NULL"; } $sql .= ' WHERE id = '.((int) $this->id); } else // Special case for old architecture objects @@ -2236,7 +2245,7 @@ abstract class CommonObject } else { $sql .= ' SET fk_projet = NULL'; } - $sql .= ' WHERE rowid = '.$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); } dol_syslog(get_class($this)."::setProject", LOG_DEBUG); @@ -2274,8 +2283,8 @@ abstract class CommonObject $fieldname = 'fk_typepayment'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2286,7 +2295,7 @@ abstract class CommonObject } return 1; } else { - dol_syslog(get_class($this).'::setPaymentMethods Error '.$sql.' - '.$this->db->error()); + dol_syslog(get_class($this).'::setPaymentMethods Error '.$this->db->error()); $this->error = $this->db->error(); return -1; } @@ -2310,7 +2319,7 @@ abstract class CommonObject $fieldname = 'multicurrency_code'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'"; + $sql .= " SET ".$fieldname." = '".$this->db->escape($code)."'"; $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2348,7 +2357,7 @@ abstract class CommonObject $fieldname = 'multicurrency_tx'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.((float) $rate); + $sql .= " SET ".$fieldname." = ".((float) $rate); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2556,7 +2565,7 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); + $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2598,7 +2607,7 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); + $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2633,7 +2642,7 @@ abstract class CommonObject $fieldname = 'retained_warranty_fk_cond_reglement'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.((int) $id); + $sql .= " SET ".$fieldname." = ".((int) $id); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2666,14 +2675,14 @@ abstract class CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".((int) $id); - $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = 0"; if ($this->db->query($sql)) { $this->fk_delivery_address = $id; return 1; } else { $this->error = $this->db->error(); - dol_syslog(get_class($this).'::setDeliveryAddress Error '.$sql.' - '.$this->error); + dol_syslog(get_class($this).'::setDeliveryAddress Error '.$this->error); return -1; } } @@ -2790,7 +2799,7 @@ abstract class CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::setDocModel", LOG_DEBUG); $resql = $this->db->query($sql); @@ -2891,8 +2900,8 @@ abstract class CommonObject // Count number of lines to reorder (according to choice $renum) $nl = 0; - $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.'='.$this->id; + $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); if (!$renum) { $sql .= ' AND rang = 0'; } @@ -2913,12 +2922,12 @@ abstract class CommonObject $rows = array(); // We first search all lines that are parent lines (for multilevel details lines) - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); if ($fk_parent_line) { $sql .= ' AND fk_parent_line IS NULL'; } - $sql .= ' ORDER BY rang ASC, rowid '.$rowidorder; + $sql .= " ORDER BY rang ASC, rowid ".$rowidorder; dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -2961,12 +2970,12 @@ abstract class CommonObject { $rows = array(); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND fk_parent_line = '.$id; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); + $sql .= ' AND fk_parent_line = '.((int) $id); $sql .= ' ORDER BY rang ASC'; - dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id."", LOG_DEBUG); + dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql) > 0) { @@ -3029,21 +3038,28 @@ abstract class CommonObject * * @param int $rowid Id of line * @param int $rang Position - * @return void + * @return int <0 if KO, >0 if OK */ public function updateRangOfLine($rowid, $rang) { + global $hookmanager; $fieldposition = 'rang'; // @todo Rename 'rang' into 'position' if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) { $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); $sql .= ' WHERE rowid = '.((int) $rowid); dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG); if (!$this->db->query($sql)) { dol_print_error($this->db); + return -1; + } else { + $parameters=array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); + $action=''; + $reshook = $hookmanager->executeHooks('afterRankOfLineUpdate', $parameters, $this, $action); + return 1; } } @@ -3078,11 +3094,11 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND rang = '.($rang - 1); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); + $sql .= ' AND rang = '.((int) ($rang - 1)); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1)); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1)); $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -3109,11 +3125,11 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); $sql .= ' AND rang = '.((int) ($rang + 1)); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1)); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1)); $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -3132,8 +3148,8 @@ abstract class CommonObject */ public function getRangOfLine($rowid) { - $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid ='.((int) $rowid); + $sql = "SELECT rang FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3151,9 +3167,9 @@ abstract class CommonObject */ public function getIdOfLine($rang) { - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND rang = '.((int) $rang); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); + $sql .= " AND rang = ".((int) $rang); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); @@ -3178,9 +3194,9 @@ abstract class CommonObject // Search the last rang with fk_parent_line if ($fk_parent_line) { - $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND fk_parent_line = '.$fk_parent_line; + $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); + $sql .= " AND fk_parent_line = ".((int) $fk_parent_line); dol_syslog(get_class($this)."::line_max", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3194,8 +3210,8 @@ abstract class CommonObject } } else { // If not, search the last rang of element - $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; + $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); dol_syslog(get_class($this)."::line_max", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3221,9 +3237,9 @@ abstract class CommonObject return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'"; - $sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".$this->id; + $sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".((int) $this->id); dol_syslog(get_class($this)."::update_ref_ext", LOG_DEBUG); if ($this->db->query($sql)) { @@ -3272,10 +3288,10 @@ abstract class CommonObject } else { $fieldusermod = "fk_user_modif"; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL"); - $sql .= " ,".$fieldusermod." = ".$user->id; - $sql .= " WHERE rowid =".$this->id; + $sql .= ", ".$fieldusermod." = ".((int) $user->id); + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_note", LOG_DEBUG); if ($this->db->query($sql)) { @@ -3390,21 +3406,21 @@ abstract class CommonObject $fieldup = 'value_unit'; } - $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; + $sql = "SELECT rowid, qty, ".$fieldup." as up, remise_percent, total_ht, ".$fieldtva." as total_tva, total_ttc, ".$fieldlocaltax1." as total_localtax1, ".$fieldlocaltax2." as total_localtax2,"; $sql .= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; if ($this->table_element_line == 'facturedet') { $sql .= ', situation_percent'; } $sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); if ($exclspec) { $product_field = 'product_type'; if ($this->table_element_line == 'contratdet') { $product_field = ''; // contratdet table has no product_type field } if ($product_field) { - $sql .= ' AND '.$product_field.' <> 9'; + $sql .= " AND ".$product_field." <> 9"; } } $sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used @@ -3444,7 +3460,7 @@ abstract class CommonObject //var_dump($diff_when_using_price_ht.' '.$diff_on_current_total); if ($diff_when_using_price_ht && $diff_on_current_total) { - $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; + $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid); dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING); $resqlfix = $this->db->query($sqlfix); if (!$resqlfix) { @@ -3488,7 +3504,7 @@ abstract class CommonObject dol_print_error('', $errmsg); exit; } - $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; + $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid); dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); $resqlfix = $this->db->query($sqlfix); if (!$resqlfix) { @@ -3556,16 +3572,16 @@ abstract class CommonObject } if (empty($nodatabaseupdate)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; - $sql .= " ".$fieldht." = ".price2num($this->total_ht).","; - $sql .= " ".$fieldtva." = ".price2num($this->total_tva).","; - $sql .= " ".$fieldlocaltax1." = ".price2num($this->total_localtax1).","; - $sql .= " ".$fieldlocaltax2." = ".price2num($this->total_localtax2).","; - $sql .= " ".$fieldttc." = ".price2num($this->total_ttc); - $sql .= ", multicurrency_total_ht = ".price2num($this->multicurrency_total_ht, 'MT', 1); - $sql .= ", multicurrency_total_tva = ".price2num($this->multicurrency_total_tva, 'MT', 1); - $sql .= ", multicurrency_total_ttc = ".price2num($this->multicurrency_total_ttc, 'MT', 1); - $sql .= ' WHERE rowid = '.$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.' SET'; + $sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).","; + $sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).","; + $sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).","; + $sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2)).","; + $sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc)); + $sql .= ", multicurrency_total_ht = ".((float) price2num($this->multicurrency_total_ht, 'MT', 1)); + $sql .= ", multicurrency_total_tva = ".((float) price2num($this->multicurrency_total_tva, 'MT', 1)); + $sql .= ", multicurrency_total_ttc = ".((float) price2num($this->multicurrency_total_ttc, 'MT', 1)); + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3602,7 +3618,7 @@ abstract class CommonObject public function add_object_linked($origin = null, $origin_id = null, $f_user = null, $notrigger = 0) { // phpcs:enable - global $user; + global $user, $hookmanager, $action; $origin = (!empty($origin) ? $origin : $this->origin); $origin_id = (!empty($origin_id) ? $origin_id : $this->origin_id); $f_user = isset($f_user) ? $f_user : $user; @@ -3620,6 +3636,20 @@ abstract class CommonObject if ($origin == 'supplierorder') { $origin = 'order_supplier'; } + + // Elements of the core modules which have `$module` property but may to which we don't want to prefix module part to the element name for finding the linked object in llx_element_element. + // It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target. + $coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization'); + // Add module part to target type if object has $module property and isn't in core modules. + $targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element; + + $parameters = array('targettype'=>$targettype); + // Hook for explicitly set the targettype if it must be differtent than $this->element + $reshook = $hookmanager->executeHooks('setLinkedObjectSourceTargetType', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (!empty($hookmanager->resArray['targettype'])) $targettype = $hookmanager->resArray['targettype']; + } + $this->db->begin(); $error = 0; @@ -3632,7 +3662,7 @@ abstract class CommonObject $sql .= ((int) $origin_id); $sql .= ", '" . $this->db->escape($origin) . "'"; $sql .= ", " . ((int) $this->id); - $sql .= ", '" . $this->db->escape($this->element) . "'"; + $sql .= ", '" . $this->db->escape($targettype) . "'"; $sql .= ")"; dol_syslog(get_class($this) . "::add_object_linked", LOG_DEBUG); @@ -3685,7 +3715,7 @@ abstract class CommonObject */ public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) { - global $conf; + global $conf, $hookmanager, $action; $this->linkedObjectsIds = array(); $this->linkedObjects = array(); @@ -3695,6 +3725,16 @@ abstract class CommonObject $withtargettype = false; $withsourcetype = false; + $parameters = array('sourcetype'=>$sourcetype, 'sourceid'=>$sourceid, 'targettype'=>$targettype, 'targetid'=>$targetid); + // Hook for explicitly set the targettype if it must be differtent than $this->element + $reshook = $hookmanager->executeHooks('setLinkedObjectSourceTargetType', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (!empty($hookmanager->resArray['sourcetype'])) $sourcetype = $hookmanager->resArray['sourcetype']; + if (!empty($hookmanager->resArray['sourceid'])) $sourceid = $hookmanager->resArray['sourceid']; + if (!empty($hookmanager->resArray['targettype'])) $targettype = $hookmanager->resArray['targettype']; + if (!empty($hookmanager->resArray['targetid'])) $targetid = $hookmanager->resArray['targetid']; + } + if (!empty($sourceid) && !empty($sourcetype) && empty($targetid)) { $justsource = true; // the source (id and type) is a search criteria if (!empty($targettype)) { @@ -3845,8 +3885,14 @@ abstract class CommonObject $classfile = 'conferenceorbooth'; $classname = 'ConferenceOrBooth'; $module = 'eventorganization'; + } elseif ($objecttype == 'mo') { + $classpath = 'mrp/class'; + $classfile = 'mo'; + $classname = 'Mo'; + $module = 'mrp'; } + // Here $module, $classfile and $classname are set if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) { if ($loadalsoobjects) { @@ -4043,7 +4089,7 @@ abstract class CommonObject global $db; - $sql = 'SELECT '.$field_select.' FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where); + $sql = "SELECT ".$field_select." FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); $resql = $db->query($sql); $TRes = array(); @@ -4072,7 +4118,7 @@ abstract class CommonObject global $db; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where); + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); $resql = $db->query($sql); if (empty($resql)) { @@ -4245,8 +4291,8 @@ abstract class CommonObject */ public function getSpecialCode($lineid) { - $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid = '.((int) $lineid); + $sql = "SELECT special_code FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $lineid); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); @@ -4297,10 +4343,10 @@ abstract class CommonObject //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; $haschild += $obj->nb; if (is_numeric($elementname)) { // old usage - $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); + $this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table); } else // new usage: $elementname=Translation key { - $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); + $this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($elementname)); } break; // We found at least one, we stop here } @@ -4364,7 +4410,7 @@ abstract class CommonObject $sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line; - $sql .= " WHERE ".$this->fk_element." = ".$this->id; + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); dol_syslog(get_class($this).'::getTotalDiscount', LOG_DEBUG); $resql = $this->db->query($sql); @@ -4505,7 +4551,7 @@ abstract class CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET extraparams = ".(!empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::setExtraParameters", LOG_DEBUG); $resql = $this->db->query($sql); @@ -4823,13 +4869,18 @@ abstract class CommonObject if (!empty($this->lines)) { foreach ($this->lines as $line) { - if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { + $reshook = 0; + //if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { + if (is_object($hookmanager)) { // Old code is commented on preceding line. if (empty($line->fk_parent_line)) { - $parameters = array('line'=>$line, 'i'=>$i); - $action = ''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); + $reshook = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + } else { + $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines, 'fk_parent_line'=>$line->fk_parent_line); + $reshook = $hookmanager->executeHooks('printOriginObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } - } else { + } + if (empty($reshook)) { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); } @@ -5297,7 +5348,7 @@ abstract class CommonObject $ecmfile->gen_or_uploaded = 'generated'; $ecmfile->description = ''; // indexed content $ecmfile->keywords = ''; // keyword content - $ecmfile->src_object_type = $this->table_element; + $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'. $ecmfile->src_object_id = $this->id; $result = $ecmfile->create($user); @@ -5317,8 +5368,8 @@ abstract class CommonObject $update_main_doc_field = 1; } if ($update_main_doc_field && !empty($this->table_element)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql .= ' WHERE rowid = '.$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath."/".$ecmfile->filename)."'"; + $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -6135,7 +6186,7 @@ abstract class CommonObject foreach ($new_array_languages as $key => $langcodearray) { // $key = 'name', 'town', ... foreach ($langcodearray as $langcode => $value) { $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."object_lang"; - $sql_del .= " WHERE fk_object = ".$this->id." AND property = '".$this->db->escape($key)."' AND type_object = '".$this->db->escape($table_element)."'"; + $sql_del .= " WHERE fk_object = ".((int) $this->id)." AND property = '".$this->db->escape($key)."' AND type_object = '".$this->db->escape($table_element)."'"; $sql_del .= " AND lang = '".$this->db->escape($langcode)."'"; $this->db->query($sql_del); @@ -6319,7 +6370,7 @@ abstract class CommonObject $linealreadyfound = 0; // Check if there is already a line for this object (in most cases, it is, but sometimes it is not, for example when extra field has been created after), so we must keep this overload) - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $tmpobj = $this->db->fetch_object($resql); @@ -6334,7 +6385,7 @@ abstract class CommonObject } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; } - $sql .= " WHERE fk_object = ".$this->id; + $sql .= " WHERE fk_object = ".((int) $this->id); } else { $result = $this->insertExtraFields('', $user); if ($result < 0) { @@ -6425,9 +6476,19 @@ abstract class CommonObject $val = $this->fields[$key]; } + // Validation tests and output + $fieldValidationErrorMsg = ''; + $validationClass = ''; + $fieldValidationErrorMsg = $this->getFieldError($key); + if (!empty($fieldValidationErrorMsg)) { + $validationClass = ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error + } else { + $validationClass = ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success + } + $out = ''; $type = ''; - $isDependList=0; + $isDependList = 0; $param = array(); $param['options'] = array(); $reg = array(); @@ -6516,6 +6577,11 @@ abstract class CommonObject } } + // Add validation state class + if (!empty($validationClass)) { + $morecss.= ' '.$validationClass; + } + if (in_array($type, array('date'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; @@ -6645,8 +6711,8 @@ abstract class CommonObject } $sqlwhere = ''; - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + $sql = "SELECT ".$keyList; + $sql .= " FROM ".MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { @@ -6662,17 +6728,17 @@ abstract class CommonObject //We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; + $sql .= " as main, ".MAIN_DB_PREFIX.$InfoFieldList[0]."_extrafields as extra"; + $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4]; } else { - $sqlwhere .= ' WHERE '.$InfoFieldList[4]; + $sqlwhere .= " WHERE ".$InfoFieldList[4]; } } else { $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = '.$conf->entity; + $sqlwhere .= " AND entity = ".((int) $conf->entity); } $sql .= $sqlwhere; //print $sql; @@ -6730,7 +6796,7 @@ abstract class CommonObject if (!empty($InfoFieldList[3]) && $parentField) { $parent = $parentName.':'.$obj->{$parentField}; - $isDependList=1; + $isDependList = 1; } $out .= '