diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 3cffed355fa..67b4b346b6c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,9 +18,10 @@ filter: - dev/* - doc/* - documents/* - - htdocs/includes/* - node_modules/* - test/* + dependency_paths: + - htdocs/includes/* paths: - htdocs/* - scripts/* diff --git a/.travis.yml b/.travis.yml index 44d784ea091..a260c31e3f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,23 +93,26 @@ install: echo - | - echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" + echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" if [ "$TRAVIS_PHP_VERSION" = '5.6' ]; then composer -n require phpunit/phpunit ^5 \ php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then composer -n require phpunit/phpunit ^6 \ php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ]; then composer -n require phpunit/phpunit ^7 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi # phpunit 9 is required for php 8 @@ -117,6 +120,7 @@ install: composer -n require --ignore-platform-reqs phpunit/phpunit ^7 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi echo @@ -166,6 +170,10 @@ before_script: which phpcs phpcs --version | head - phpcs -i | head - + # Check PHP Vardump check version + echo "PHP Vardump check version" + which var_dump_check + var_dump_check --version # Check PHPUnit version echo "PHPUnit version" which phpunit @@ -297,6 +305,17 @@ script: set +e echo +- | + echo "Checking missing debug" + # Ensure we catch errors + set -e + # Exclusions are defined in the ruleset.xml file + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then + var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php . + fi + set +e + echo + - | export INSTALL_FORCED_FILE=htdocs/install/install.forced.php echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" diff --git a/COPYRIGHT b/COPYRIGHT index a2101a1db0a..de293e3867e 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -24,7 +24,6 @@ Component Version License GPL Compatible ------------------------------------------------------------------------------------- PHP libraries: ADOdb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package) -CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG EvalMath 1.0 BSD Yes Safe math expressions evaluation Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert @@ -50,6 +49,7 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes JS libraries: Ace 1.4.14 BSD Yes JS library to get code syntaxique coloration in a textarea. ChartJS 3.7.1 MIT License Yes JS library for graph +CKEditor 4.18 LGPL-2.1+ Yes Editor WYSIWYG jQuery 3.6.0 MIT License Yes JS library jQuery UI 1.13.1 GPL and MIT License Yes JS library plugin UI jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css diff --git a/ChangeLog b/ChangeLog index 1a0a95aab9e..37957f61c1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,21 +9,178 @@ English Dolibarr ChangeLog For users: --------------- -NEW: PHP 8.0 compatibility - - +NEW: PHP 8.1 compatibility +NEW: Support for recurring purchase invoices. +NEW: #20292 Include German public holidays +NEW: Can show ZATCA QRCode on PDFs +NEW: #17123 added ExtraFields for Stock Mouvement +NEW: #20609 : new massaction to assign a sale representatives on a selection of thirdparties +NEW: #20653 edit discount pourcentage for all lines in one shot +NEW: Accept 'auto' for ref of object on import of purchase order/proposal +NEW: Accountancy - Add more filters and info on page to bind accounting accounts +NEW: Accountancy - Add subledger account when we generate a transaction with a deposit invoice +NEW: Accountancy - Add a massaction to preselect an account (customer and supplier list) +NEW: ACE Editor is restored at same cursor position after a save. +NEW: Add "addMoreActionsButtons" hook to subscription form +NEW: Add an option in GUI to show a Quick add button into top menu bar +NEW: Module Recruitment - Add a public page with all list of open job positions. +NEW: Module Recruitment - Add a tab with list of application on the jobposition file. +NEW: Add a workflow to auto link contract on a ticket +NEW: Add column date of Signature on proposal list +NEW: Add column template invoice in invoice list +NEW: Add column "Total HT" to products array on document creation card +NEW: ADD configuration for text color of button action +NEW: Add constant to hide categories in TakePos +NEW: Add constant to show category description in TakePos +NEW: Add constant to show only the products in stock in TakePos +NEW: Add entity filter in exports +NEW: Show the event block on recurring invoices #20870 +NEW: Add filter "opportunity status" on statistics of projects. +NEW: Add firstname, lastname and max number of attendees for module "Event Organization" +NEW: add margin info in proposal and order list +NEW: Add massaction "Edit Extrafield" for Product +NEW: Add more fields to detect duplicate during import of thirdparties +NEW: Add option to foce delivery on email for purchase order receipt to yes +NEW: Add param boder table for md theme +NEW: Add param color button action +NEW: Add possibility to create contract from invoice +NEW: Add possibility with constant MAIN_LOGIN_BADCHARUNAUTHORIZED to define bad character unauthorized into login name +NEW: Add private and public notes on tax files. +NEW: Add status "Obsolete" to KM articles +NEW: Add substitutions "user numbers" +NEW: Add the possibility to add sub-BOMs to BOM +NEW: allow a ticket to be automatically marked as read when created from backend. +NEW: allow cut&paste as real numeric value to excel +NEW: A public form to send a message and create a lead is available +NEW: automatically set totally received status in reception +NEW: Auto set invoice paid when adding credit not and remain to pay is 0 +NEW: Availibility dictionnary has a new column unit and number +NEW: barcode rule to insert product in takepos +NEW: Can change value of AWP during the inventory +NEW: Can enter price with tax for predefined products on purchase objects +NEW: Can filter on a thirdparty on product statistics +NEW: Can removed doc templates from setup page of thirdparty +NEW: Can set the parent company during the creation of thirdparty (action=add of societe/card.php) +NEW: Can use ! to make a search that exclude a string +NEW: Change in theme colors does not need to use the refresh button +NEW: clean values and amount in FEC import +NEW: const MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND for mailing mass action +NEW: Contact filter project list +NEW: Create contract from invoice +NEW: create third-party with contact if not found on public ticket +NEW: Default value for MAIN_SECURITY_CSRF_WITH_TOKEN is now 2 (GET are also protected agains CSRF attacks) +NEW: deposit payment terms: add field into dictionary admin page to define default percentage of deposit. +NEW: Dictionaries - add possibility to manage countries in EEC +NEW: display errors in a message box after generating documents +NEW: Display physical and virtual stock of the products when creating OF from a BOM +NEW: Display product ref in "Object link" product tab for BOM +NEW: Enhance the import. Can use 'auto' for the ref (import of orders) +NEW: Events on Proposal to Return to Draft +NEW: Page to list expense report payments +NEW: JS inventory autocalc input +NEW: language support for more emailing target selectors +NEW: leave requests: add field into type dictionary to block request if balance is negative +NEW: MAIN_MAIL_AUTOCOPY_TO can accept several email and special keys +NEW: MAIN_SEARCH_CAT_OR_BY_DEFAULT const for search by category +NEW: Mass action "Close shipments" +NEW: Module website now supports the multicompany module +NEW: More mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) +NEW: Add option to move checkbox column as first column on Thirdparty list (only few screens) +NEW: Add tabs for nets Bom +NEW: on redirect of page in website module, GET parameters are kept. +NEW: optional display warning icons on ticket list +NEW: option to default check "notify tier at creation" in ticket module +NEW: option update prices on proposal cloning +NEW: payment conditions enabling semi-automatic deposit creation (Issue #18439) +NEW: possibility to consume multiple batch +NEW: Reverse movement product consumption +NEW: Send email to the supplier order contact +NEW: New permission to report time on timesheet. +NEW: SEPA XML - option to place payment Type Info at Credit transfer Transaction level +NEW: Show number of votes into the label of tab "Results" of a survey +NEW: Show product reference in Takepos +NEW: Some core tables are created only at module activation +NEW: split consumption line on MO +NEW: stock filter in reassort lists +NEW: stock limit in stock export CSV +NEW: Sub-bom are availables +NEW: Supplier order - Show ref supplier of reception in linked object block +NEW: support user_modif in order +NEW: TakePos - pagination on search results +NEW: The backup tools has an "lowmemory" option for mysqldump on large database +NEW: The 'reposition' class works on ajax constantonoff that make redirects +NEW: Thirdparty - Add rules "customer accountancy code" is mandatory to validate invoice +NEW: thumbnail field in product list +NEW: total mark rate in list +NEW: uncheck "send message" by default on a ticket when private messages has been checked +NEW: VAT Report by month - Show detail by rate and also by code +NEW: Ticket triggers: allow to automatically send messages on new tickets +NEW: Accountancy - Add hidden feature for accounting reconciliation +NEW: Can store the session into database (instead of beeing managed by PHP) Modules +NEW: Module Partnership Management NEW: Experimental module Event Organization Management -NEW: Experimental module Workstations Management -NEW: Experimental module Partnership Management -For developers: ---------------- - -NEW: A lot of addition of hooks. - +For developers or integrators: +------------------------------ +NEW: dol_uncompress() supports more extensions (.gz, .bz2, .zstd). Only .zip was supported before. +NEW: Implement a generic method for Kaban views +NEW: Upgrade chartjs library to 3.7.1 +NEW: update rank line is possible on API for customer invoices, sales orders and supplier invoice +NEW: stripe element with more gateways +NEW: solde() function evolution to be able to get solde until a chosen date +NEW: Suggest a way to run upgrade per entities. +NEW: Support html content for multiselect component. +NEW: ModuleBuilder - Add tabs view in module builder +NEW: ModuleBuilder - More feature that can be modifed after module generation +NEW: Hook getNomUrl available everywhere in tooltip of ref links +NEW: Identification of tr is possible with by attribute data-id on some pages +NEW: Import with select boxes V2 +NEW: Can update rank of invoice, proposal and order lines with API update +NEW: Can use current entity filter on 'chkbxlst' +NEW: Creation of the function select_bom() used to display bom select list +NEW: add printFieldListWhere hook in product reassort card +NEW: Add trigger and event on completely received status change +NEW: Add utility function send backup by mail +NEW: add WordPress OAuth to save a token (not SSO) +NEW: A module can embed a sql script run at each Dolibarr upgrade +NEW: API Proposals - Add POST lines +NEW: API REST filter states by country +NEW: Add option INVOICEREC_SET_AUTOFILL_DATE_START/END +NEW: Add option MAIN_API_DEBUG to save API logs into a file +NEW: Add param to keep the robot=index meta tag on public pages +NEW: Add method hintindex() in database handlers. +NEW: add modifications for new function "$db->prefix()" +NEW: addMoreActionsButtonsList hook for button in list +NEW: Add API to get a template invoice +NEW: Standardize a lot of code. +NEW: #20736 Allow extrafields SQL filters on REST API product lookup +NEW: #19294 implement detailed timespent in task of project API +NEW: Add a protection into PHPunit to avoid to forget a var_dump +NEW: Add datem and type parameters to API to create movements +NEW: Add hidden option on contract PDF line to hide qty and price +NEW: Option MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND to send last document in mass mailing action +NEW: Add hooks: selectContactListWhere hook, selectThirdpartyListWhere hook +NEW: TakePos - add hooks complete product display +NEW: TakePos - add hooks for cart display +NEW: TakePos - add hooks to complete ajax return array +NEW: Add hook before the public ticket list +NEW: Add hook doaction in takepos invoice +NEW: Add Hook for Notif +NEW: Add hook for more buttons +NEW: Add hook printFieldListWhere in "show_contacts" function +NEW: Add hook printFieldWhere in load_state_board function +NEW: Add hooks contact tab badge and hooks parameter for avoid conflicts +NEW: Add hook selectProductsListWhere in select_produits_list function +NEW: Add hooks in commercial index +NEW: Add hooks in customers and products boxes +NEW: Add hooks in thirdparty index page +NEW: Add hooks on project task time page +NEW: Add hooks on salaries and sociales card +NEW: Add hooks select product list and select thirdparty list function +NEW: Add hook to getSellPrice function Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: @@ -39,6 +196,105 @@ Following changes may create regressions for some external modules, but were nec * Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php * Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code). * Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions. +* The hook 'upgrade' and 'doUpgrade2" has been renamed 'doUpgradeBefore' and 'doUpgradeAfterDB'. A new trigger 'doUpgradeAfterFiles' has been introduced. + + + +***** ChangeLog for 15.0.2 compared to 15.0.1 ***** + +FIX: #19777 #20281 +FIX: #20140 #20301 +FIX: #20279 Accountancy - PostGreSQL - Error on mass update lines already binded +FIX: #20476 migration postgresql 14.0.x to 15.0.x packaging type +FIX: #20733 Inventory: Do not use batch qty even if present if batch module is disabled. +FIX: action comm list: holiday last day not included + handle duration with halfdays +FIX: Add missing entity on salary's payment +FIX: Add 'recruitment' into check array +FIX: add tools to fix bad bank amount in accounting with multicurrency +FIX: assign member cateogry to a member +FIX: backport +FIX: bad bank amount in accounting with multicurrency +FIX: Bad condition on remx +FIX: Bad filter on date on salary list +FIX: bad link to add a customer price (token duplicated) +FIX: bad status of member on widget by type and status +FIX: better error management at product selling price update +FIX: Can't edit bank record +FIX: check mandatory thirdparty fields for mass action +FIX: check thirdparty object loaded and properties exist +FIX: comment +FIX: compatibility for ticket number sharing +FIX: compatibility with multicompany sharings +FIX: contact card: single extrafield update failed +FIX: country not visible into list of states +FIX: Delete an extrafield where type is double +FIX: deprecated module are not more viewed as external modules +FIX: Disable customer type by default if type prospect/customer is disabled +FIX: each time we create a supplier order, we need to give it a ref_supplier +FIX: Error management +FIX: fatal error for $db usage in tpl +FIX: filter into the list of product lots +FIX: Filter on Object Referent page give CRSF page +FIX: Fix default options ($hidedetails, $hidedesc, $hideref) with globales when generate PDF in mass actions +FIX: Fix search by filters +FIX: Fix the adding of lines in the create invoice functions +FIX: forgotten form confirm before various payment delete +FIX: holiday/leave requests: write status change emails in HTML +FIX: include discount price for PMP after a reception (Issue #20029) +FIX: incrementation +FIX: in salary stats and payment list, we must check right perms as well as salary list +FIX: intervention entity missing +FIX: label tax cat trad +FIX: Mass action ship orders +FIX: missing advanced perms +FIX: missing call to executeHooks() +FIX: Missing entity on adding new VAT +FIX: missing hook for row ordering +FIX: missing hook parameter ($possiblelinks) +FIX: missing parenthesis +FIX: missing picto in combo of mass actions of thirdparties. +FIX: missing signature library when ODT model is used +FIX: Missing unset fields after updateline expensereport +FIX: ModuileBuilder - Fix getLinesArray() error reporting +FIX: Move delete task time trigger position +FIX: Navigation between invoices +FIX: No empty line inserted into accounting_bookkeeping +FIX: Numbering of sepa files +FIX: object cloning: set unique extrafield values to null to prevent duplicates +FIX: on update with action reminder in future there is user key error +FIX: originproductline array td identification data-id +FIX: out of memory when more than 100 000 invoices. +FIX: permit access to medias when logged in a different entity +FIX: phpcs +FIX: project creation prevented if PROJECTLEADER contact role renamed, de-activated or deleted +FIX: project timesheet by week: cleanup unused code +FIX: project timesheet: public holidays offset by 1 day +FIX: project timesheets: assume Saturday and Sunday as default weekend days when working days conf is empty or badly formed +FIX: propal list: bad error management when setting "not signed" mass action +FIX: propal list mass action translations and error management (v14 edition) +FIX: propal list: missing not signed massaction translation keys for transifex +FIX: PR returns +FIX: ref_client doesn't exists on supplier invoice, then ref_fourn needs to have a default value when we want to bill several supplier orders +FIX: replenish and manage product stock by warhouse +FIX: sending email on payment of registration of event +FIX: SEPA ICS is not mandatory for bank transfer +FIX: Set datec when add time spent on a project task +FIX: status filter on supplierOrder stats doesn't work +FIX: stickler-ci +FIX: still prevent project creation if PROJECTLEADER role unavailable, but with a specific error message +FIX: Supplier order stats +FIX: Tabulation must be allowed for HTML content +FIX: tool to fix bank account not in main currency for vendor invoice +FIX: translations +FIX: Travis + Update dev +FIX: truncate Customer Reference too long on PDF header (PR #20718) +FIX: uniformize code +FIX: Update of sale price (log not correctly updated) +FIX: user actions rights when mulit-company transverse mode is enabled +FIX: user employee tab: offset in open days messes up holiday length calculation +FIX: We need to have a different default_ref_supplier for each new fourn invoice +FIX: "WHERE" clause missing on resource export +FIX: #yogosha9754 ***** ChangeLog for 15.0.1 compared to 15.0.0 ***** @@ -150,8 +406,9 @@ 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: mass action validate on supplier orders list +NEW: mass action send email to all attendees of an event +NEW: mass action to switch status on sale / on purchase of a product 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) @@ -172,7 +429,7 @@ 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 NEW: External backups can be downloaded from the "About info page". -NEW: Add massaction to switch status on sale / on purchase of a product. + Modules @@ -180,36 +437,49 @@ NEW: Stable module Knowledge Management NEW: Experimental module Event Organization Management NEW: Experimental module Workstations Management NEW: Development of module Partnership Management +OLD: module SimplePOS has been completely removed -> use TakePOS For developers: --------------- +API: +NEW: #18319 REST API - Shipment: Add 'close' action / endpoint / POST method. +NEW: add API /approve and /makeOrder for purchase orders +NEW: API for knowledgemanagement +NEW: API get list of legal form of business +NEW: API list of staff units +NEW: Hidden option API_DISABLE_COMPRESSION is now visible in API setup page. + +Hook: +NEW: add hook 'beforeBodyClose' +NEW: add hook 'hookGetEntity' +NEW: add hook 'menuLeftMenuItems' to filter the leftmenu items +NEW: add hook 'printUnderHeaderPDFline' on invoice PDF templates (can be used for example to add a barcode or more information on header of invoices). +NEW: add hookmanager on note pages +NEW: hook after rank update +NEW: 'printFieldListFrom' hook call on several lists + +ModuleBuilder: +NEW: add the property "copytoclipboard" in modulebuilder +NEW: Use lang selector when using a field key 'lang' in modulebuilder + +Options: +NEW: add options MAIN_IBAN_IS_NEVER_MANDATORY, MAIN_IBAN_NOT_MANDATORY, PROPAL_NOT_BILLABLE, PROPAL_REOPEN_UNSIGNED_ONLY, PROPOSAL_ARE_NOT_BILLABLE, TICKETS_MESSAGE_FORCE_MAIL + +Trigger: +NEW: add action trigger for member excluded + + 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 API /approve and /makeOrder for purchase orders. -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: add code codebar column on serial/lot structure +NEW: add date_valid and date_approve columns in the list of supplier orders 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 NEW: Experimental feature to manage user sessions in database -NEW: Hidden option API_DISABLE_COMPRESSION is now visible in API setup page. -NEW: Add hook printUnderHeaderPDFline on invoice PDF templates (can be used for example to add a barcode or more information on header of invoices). + Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * ALL EXTERNAL MODULES THAT WERE NOT CORRECTLY DEVELOPPED WILL NOT WORK ON V15 (All modules that forgot to manage the security token field @@ -1066,7 +1336,6 @@ NEW: introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM NEW: introducing new modal boxes in TakePOS NEW: keep TakePOS terminal when login/logout NEW: link on balance to the ledger -NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector NEW: manage errors on update extra fields in ticket card NEW: mass-actions for the event list view NEW: more filter for "View change logs" diff --git a/README.md b/README.md index 5559613eaa2..c476f14a8cc 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Other licenses apply for some included dependencies. See [COPYRIGHT](https://git If you have low technical skills and you're looking to install Dolibarr ERP/CRM in just a few clicks, you can use one of the packaged versions: -- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_DoliWamp) +- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_(DoliWamp)) - [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian) - DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia diff --git a/SECURITY.md b/SECURITY.md index c55d6d26ab0..cd3156bece9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,8 +6,9 @@ This file contains some policies about the security reports on Dolibarr ERP CRM | Version | Supported | | ---------- | ---------------------- | -| <= 14.0.4 | :x: | -| >= 14.0.5+ | :white_check_mark: except CSRF attacks| +| <= 15.0.0 | :x: | +| >= 15.0.1+ | :white_check_mark: except CSRF attacks| +| >= 16.0.0 | :white_check_mark: | | >= develop | :white_check_mark: | ## Reporting a Vulnerability diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index dbf74a96f67..c316e0f91d6 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -27,12 +27,12 @@ OutputBaseFilename=__FILENAMEEXEDOLIWAMP__ ;SourceDir=Z:\home\ldestailleur\git\dolibarrxxx SourceDir=..\..\.. AppId=doliwamp -AppPublisher=NLTechno -AppPublisherURL=https://www.nltechno.com +AppPublisher=DoliCloud +AppPublisherURL=https://www.dolicloud.com AppSupportURL=https://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql software. -AppCopyright=Copyright (C) 2008-2020 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) +AppCopyright=Copyright (C) 2008-2022 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING @@ -99,13 +99,12 @@ Source: "build\exe\doliwamp\startdoliwamp_manual_donotuse.bat.install"; DestDir: Source: "build\exe\doliwamp\builddemosslfiles.bat.install"; DestDir: "{app}\"; Flags: ignoreversion; Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversion; -; PhpMyAdmin, Apache, Php, Mysql +; Apache, Php, Mysql ; Put here path of Wampserver applications ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) ; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) -Source: "C:\wamp64\apps\phpmyadmin4.9.2\*.*"; DestDir: "{app}\apps\phpmyadmin4.9.2"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" ;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" ;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" @@ -125,9 +124,7 @@ Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversi Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,default.properties,install.lock" ; Config files -Source: "build\exe\doliwamp\phpmyadmin.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; Source: "build\exe\doliwamp\dolibarr.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; -Source: "build\exe\doliwamp\config.inc.php.install"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion; ;Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.9\conf"; Flags: ignoreversion; Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.41\conf"; Flags: ignoreversion; Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion; @@ -196,7 +193,6 @@ var destFileA: String; var srcContents: String; var browser: String; var mysqlVersion: String; -var phpmyadminVersion: String; var phpDllCopy: String; var batFile: String; @@ -246,7 +242,6 @@ begin phpVersion := '7.3.12' ; //mysqlVersion := '5.0.45'; mysqlVersion := '10.4.10'; - phpmyadminVersion := '4.1.14'; smtpServer := 'localhost'; apachePort := '80'; @@ -635,27 +630,6 @@ begin begin - //---------------------------------------------- - // Create file alias phpmyadmin (always) - //---------------------------------------------- - - destFile := pathWithSlashes+'/alias/phpmyadmin.conf'; - srcFile := pathWithSlashes+'/alias/phpmyadmin.conf.install'; - - if FileExists(srcFile) then - begin - LoadStringFromFile (srcFile, srcContents); - - //installDir et version de phpmyadmin - StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True); - StringChangeEx (srcContents, 'WAMPPHPMYADMINVERSION', phpmyadminVersion, True); - - SaveStringToFile(destFile,srcContents, False); - end; - DeleteFile(srcFile); - - - //---------------------------------------------- // Create file alias dolibarr (if not exists) //---------------------------------------------- @@ -691,35 +665,6 @@ begin - //---------------------------------------------- - // Create file configuration for phpmyadmin (if not exists) - //---------------------------------------------- - - destFile := pathWithSlashes+'/apps/phpmyadmin'+phpmyadminVersion+'/config.inc.php'; - srcFile := pathWithSlashes+'/apps/phpmyadmin'+phpmyadminVersion+'/config.inc.php.install'; - - if FileExists(srcFile) then - begin - if not FileExists (destFile) then - begin - LoadStringFromFile (srcFile, srcContents); - StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True); - StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True); - SaveStringToFile(destFile,srcContents, False); - end - else - begin - // We must replace to use format 2.4 of apache - DeleteFile(destFile); - LoadStringFromFile (srcFile, srcContents); - StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True); - StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True); - SaveStringToFile(destFile,srcContents, False); - end; - end; - - - //---------------------------------------------- // Create file httpd.conf (if not exists) //---------------------------------------------- diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 906601d94d4..b648bd7aff7 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -582,9 +582,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/webmail*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`; - $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/theme/common/fontawesome-5/svgs`; # Removed other test files $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`; diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 204988c5442..cbfecbbc19f 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -275,6 +275,13 @@ RESTLER: with $loaders = array_unique(static::$rogueLoaders, SORT_REGULAR); + +* Replace CommentParser.php line 423 + elseif (count($value) && is_numeric($value[0])) + + with + + elseif (count($value) && isset($value[0]) && is_numeric($value[0])) +With swagger 2 provided into /explorer: diff --git a/dev/setup/git/hooks/pre-commit b/dev/setup/git/hooks/pre-commit index 51b7c5cf4e9..55295b4d656 100644 --- a/dev/setup/git/hooks/pre-commit +++ b/dev/setup/git/hooks/pre-commit @@ -7,7 +7,7 @@ # To run the fix manually: cd ~/git/dolibarr; phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true "fileordir" PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"` -STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php` +STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep -v '/includes/'| grep \\\\.php` DIRPHPCS="" AUTOFIX=1 diff --git a/dev/tools/test/namespacemig/main.inc.php b/dev/tools/test/namespacemig/main.inc.php index 555a4b36ff5..d46d8e38c1c 100644 --- a/dev/tools/test/namespacemig/main.inc.php +++ b/dev/tools/test/namespacemig/main.inc.php @@ -1,7 +1,7 @@ banque->enabled) { +if (!empty($conf->banque->enabled)) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } -if ($conf->don->enabled) { +if (!empty($conf->don->enabled)) { $list_account[] = 'DONATION_ACCOUNTINGACCOUNT'; } -if ($conf->adherent->enabled) { +if (!empty($conf->adherent->enabled)) { $list_account[] = 'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'; } -if ($conf->loan->enabled) { +if (!empty($conf->loan->enabled)) { $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'; } -if ($conf->societe->enabled) { +$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; +if (!empty($conf->societe->enabled)) { + $list_account[] = '---Deposits---'; $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; } -$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; /* * Actions @@ -134,6 +135,20 @@ if ($action == 'update') { } } +if ($action == 'setdisableauxiliaryaccountoncustomerdeposit') { + $setDisableAuxiliaryAccountOnCustomerDeposit = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT", $setDisableAuxiliaryAccountOnCustomerDeposit, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View @@ -231,6 +246,20 @@ foreach ($list_account as $key) { } } +if (!empty($conf->societe->enabled)) { + print ''; + print '' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . ''; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; +} print "\n"; print "\n"; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 03cd41a43a9..430c7b6abae 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -47,7 +47,8 @@ $main_option = array( 'ACCOUNTING_EXPORT_PREFIX_SPEC', ); -$configuration = AccountancyExport::getTypeConfig(); +$accountancyexport = new AccountancyExport($db); +$configuration = $accountancyexport->getTypeConfig(); $listparam = $configuration['param']; @@ -117,7 +118,7 @@ if ($action == 'update') { if (!$error) { // reload - $configuration = AccountancyExport::getTypeConfig(); + $configuration = $accountancyexport->getTypeConfig(); $listparam = $configuration['param']; setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -237,7 +238,7 @@ if (!$conf->use_javascript_ajax) { print ""; } else { print ''; - $listmodelcsv = AccountancyExport::getType(); + $listmodelcsv = $accountancyexport->getType(); print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ''; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 1a682636077..c8cb62cd7e0 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -395,8 +395,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; @@ -406,9 +406,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; $param = ''; @@ -608,7 +608,7 @@ if ($result) { $i = 0; while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); // Ref produit as link $product_static->ref = $obj->ref; @@ -891,7 +891,7 @@ if ($result) { print ''; - $db->free($result); + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 3c2e8763fe1..7a65fa0ffaa 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -349,7 +349,7 @@ if ($action != 'export_csv') { $sql .= " GROUP BY t.numero_compte"; $resql = $db->query($sql); - $nrows = $resql->num_rows; + $nrows = $db->num_rows($resql); $opening_balances = array(); for ($i = 0; $i < $nrows; $i++) { $arr = $resql->fetch_array(); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 511b12de3c2..a1c145840a9 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -431,12 +431,12 @@ if ($action == 'create') { // Account movement print ''; print ''.$langs->trans("NumMvts").''; - print ''.$object->piece_num.''; + print ''.($mode == '_tmp' ? ''.$langs->trans("Draft").'' : $object->piece_num).''; print ''; // Date print ''; - print ''."\n"; +print 'global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '').'>'."\n"; // Address print ''."\n"; +print ''."\n"; // Zip print ''."\n"; +print ''."\n"; print ''."\n"; +print ''."\n"; // Country print ''; +print ''; // GDPR contact print ''; +print 'global->MAIN_INFO_GDPR) ? $conf->global->MAIN_INFO_GDPR : ''))).'">'; // Capital print ''; +print ''; // Juridical Status print ''; print '
'; + print ''; if ($action != 'editdate') { @@ -540,7 +540,7 @@ if ($action == 'create') { print ''; print ''; - // Date document creation + // Date document export print ''; print ''; print ''; print ''; - // Date document creation + // Date document validation print ''; print ''; print '\n"; - // Empty line is the first line of $object->linesmvt - // So we must get the first line (the empty one) and put it at the end of the array - // in order to display it correctly to the user - $empty_line = array_shift($object->linesmvt); - $object->linesmvt[]= $empty_line; + // Add an empty line if there is not yet + if (!empty($object->linesmvt[0])) { + $tmpline = $object->linesmvt[0]; + if (!empty($tmpline->numero_compte)) { + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; + } + } foreach ($object->linesmvt as $line) { print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ce0714d5651..2ee947bf720 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -204,7 +204,8 @@ if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { unset($arrayfields['t.lettering_code']); } -$listofformat = AccountancyExport::getType(); +$accountancyexport = new AccountancyExport($db); +$listofformat = $accountancyexport->getType(); $formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; if (empty($listofformat[$formatexportset])) { $formatexportset = 1; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 128b14fa800..c8c4099e67e 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild * Copyright (C) 2020 Guillaume Alexandre + * Copyright (C) 2022 Joachim Kueter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; /** @@ -93,11 +95,13 @@ class AccountancyExport */ public function __construct(DoliDB $db) { - global $conf; + global $conf, $hookmanager; $this->db = $db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n"); + + $hookmanager->initHooks(array('accountancyexport')); } /** @@ -105,9 +109,9 @@ class AccountancyExport * * @return array of type */ - public static function getType() + public function getType() { - global $langs; + global $langs, $hookmanager; $listofexporttypes = array( self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), @@ -132,6 +136,10 @@ class AccountancyExport self::$EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert', ); + // allow modules to define export formats + $parameters = array(); + $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes); + ksort($listofexporttypes, SORT_NUMERIC); return $listofexporttypes; @@ -168,7 +176,12 @@ class AccountancyExport self::$EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert', ); - return $formatcode[$type]; + global $hookmanager; + $code = $formatcode[$type]; + $parameters = array('type' => $type); + $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code); + + return $code; } /** @@ -176,11 +189,11 @@ class AccountancyExport * * @return array of type */ - public static function getTypeConfig() + public function getTypeConfig() { global $conf, $langs; - return array( + $exporttypes = array( 'param' => array( self::$EXPORT_TYPE_CONFIGURABLE => array( 'label' => $langs->trans('Modelcsv_configurable'), @@ -265,6 +278,11 @@ class AccountancyExport 'txt' => $langs->trans("txt") ), ); + + global $hookmanager; + $parameters = array(); + $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes); + return $exporttypes; } @@ -350,7 +368,13 @@ class AccountancyExport $this->exportiSuiteExpert($TData); break; default: - $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); + global $hookmanager; + $parameters = array('format' => $formatexportset); + // file contents will be created in the hooked function via print + $reshook = $hookmanager->executeHooks('export', $parameters, $TData); + if ($reshook != 1) { + $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); + } break; } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index ac943180b58..8cccef2d342 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -586,11 +586,11 @@ class AccountingAccount extends CommonObject $sql .= ' WHERE a.rowid = ' . ((int) $id); dol_syslog(get_class($this) . '::info sql=' . $sql); - $result = $this->db->query($sql); + $resql = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; if ($obj->fk_user_author) { $cuser = new User($this->db); @@ -605,7 +605,7 @@ class AccountingAccount extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } - $this->db->free($result); + $this->db->free($resql); } else { dol_print_error($this->db); } @@ -741,13 +741,14 @@ class AccountingAccount extends CommonObject global $hookmanager; // Instantiate hooks for external modules - $hookmanager->initHooks(array('accoutancyBindingCalculation')); + $hookmanager->initHooks(array('accountancyBindingCalculation')); - // Execute hook accoutancyBindingCalculation + // Execute hook accountancyBindingCalculation $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 + $reshook = $hookmanager->executeHooks('accountancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + $const_name = ''; if ($type == 'customer') { $const_name = "SOLD"; } elseif ($type == 'supplier') { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 21b723b003b..992b885f272 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -606,9 +606,13 @@ class BookKeeping extends CommonObject if (empty($this->credit)) { $this->credit = 0; } + if (empty($this->montant)) { + $this->montant = 0; + } $this->debit = price2num($this->debit, 'MT'); $this->credit = price2num($this->credit, 'MT'); + $this->montant = price2num($this->montant, 'MT'); $now = dol_now(); @@ -1661,11 +1665,10 @@ class BookKeeping extends CommonObject $this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_ref = $obj->doc_ref; $this->doc_type = $obj->doc_type; - $this->date_creation = $obj->date_creation; - $this->date_modification = $obj->date_modification; - $this->date_export = $obj->date_export; - $this->date_validation = $obj->date_validated; - $this->date_validation = $obj->date_validation; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->date_export = $this->db->jdate($obj->date_export); + $this->date_validation = $this->db->jdate($obj->date_validation); } else { $this->error = "Error ".$this->db->lasterror(); dol_syslog(__METHOD__.$this->error, LOG_ERR); @@ -1843,8 +1846,8 @@ class BookKeeping extends CommonObject /** * Transform transaction * - * @param number $direction If 0 tmp => real, if 1 real => tmp - * @param string $piece_num Piece num + * @param number $direction If 0: tmp => real, if 1: real => tmp + * @param string $piece_num Piece num = Transaction ref * @return int int <0 if KO, >0 if OK */ public function transformTransaction($direction = 0, $piece_num = '') @@ -1862,57 +1865,82 @@ class BookKeeping extends CommonObject if ($next_piecenum < 0) { $error++; } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (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, piece_num, date_creation)'; - $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, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + // Delete if there is an empty line + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0"; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (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, piece_num, date_creation)'; + $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, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } + } + + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } } elseif ($direction == 1) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, 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, piece_num)'; - $sql .= ' SELECT doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, 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, piece_num'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, 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, piece_num)'; + $sql .= ' SELECT doc_date, doc_type,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, 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, piece_num'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } } if (!$error) { diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a2718973185..405a630942e 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -266,14 +266,14 @@ class Lettering extends BookKeeping $sql .= " ORDER BY ab2.lettering_code DESC"; $sql .= " LIMIT 1 "; - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $resqla = $this->db->query($sql); + if ($resqla) { + $obj = $this->db->fetch_object($resqla); $lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code); if (!empty($obj->lettering_code)) { $lettre++; } - $this->db->free($result); + $this->db->free($resqla); } else { $this->errors[] = 'Error'.$this->db->lasterror(); $error++; @@ -281,14 +281,14 @@ class Lettering extends BookKeeping $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $resqlb = $this->db->query($sql); + if ($resqlb) { + $obj = $this->db->fetch_object($resqlb); if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); $error++; } - $this->db->free($result); + $this->db->free($resqlb); } else { $this->errors[] = 'Erreur sql'.$this->db->lasterror(); $error++; @@ -699,6 +699,8 @@ class Lettering extends BookKeeping return $grouped_payments; } + $save_payment_by_element = null; + $save_element_by_payment = null; if ($element_id == 0) { // Save list when is the begin of recursive function $save_payment_by_element = $payment_by_element; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index bc6713f0846..b9ea4fc0e54 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013-2021 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -46,6 +47,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); +$default_account = GETPOST('default_account', 'int'); // Select Box $mesCasesCochees = GETPOST('toselect', 'array'); @@ -434,12 +436,15 @@ if ($result) { $arrayofmassactions = array( 'ventil'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate") + ,'set_default_account'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount") //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + if ($massaction !== 'set_default_account') { + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + } print '
'."\n"; print ''; @@ -454,6 +459,14 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + if ($massaction == 'set_default_account') { + $formquestion[]=array('type' => 'other', + 'name' => 'set_default_account', + 'label' => $langs->trans("AccountancyCode"), + 'value' => $formaccounting->select_account('', 'default_account', 1, array(), 0, 0, 'maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone')); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($toselect)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); + } + print ''.$langs->trans("DescVentilTodoCustomer").'

'; if ($msg) { @@ -712,7 +725,7 @@ if ($result) { // Suggested accounting account print '
'; // Column with checkbox @@ -721,6 +734,14 @@ if ($result) { if (!empty($suggestedid) && $suggestedaccountingaccountfor != '' && $suggestedaccountingaccountfor != 'eecwithoutvatnumber') { $ischecked = 1; } + + if (!empty($toselect)) { + $ischecked = 0; + if (in_array($objp->rowid."_".$i, $toselect)) { + $ischecked=1; + } + } + print ''; print ''; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 18277eb6751..99ae0bd845b 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -86,7 +86,7 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S print ''.$langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")."\n"; print "
"; -} elseif ($conf->accounting->enabled) { +} elseif (!empty($conf->accounting->enabled)) { $step = 0; $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 8a02ac3849a..781218be04a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -558,11 +558,11 @@ if ($result) { } -/*var_dump($tabpay); -var_dump($tabcompany); -var_dump($tabbq); -var_dump($tabtp); -var_dump($tabtype);*/ +//var_dump($tabpay); +//var_dump($tabcompany); +//var_dump($tabbq); +//var_dump($tabtp); +//var_dump($tabtype); // Write bookkeeping if (!$error && $action == 'writebookkeeping') { @@ -594,9 +594,9 @@ if (!$error && $action == 'writebookkeeping') { $db->begin(); // Introduce a protection. Total of tabtp must be total of tabbq - /*var_dump($tabpay); - var_dump($tabtp); - var_dump($tabbq);exit;*/ + //var_dump($tabpay); + //var_dump($tabtp); + //var_dump($tabbq);exit; // Bank if (!$errorforline && is_array($tabbq[$key])) { @@ -1267,9 +1267,9 @@ if (empty($action) || $action == 'view') { $accounttoshowsubledger = length_accounta($k); if ($accounttoshow != $accounttoshowsubledger) { if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { - /*var_dump($tabpay[$key]); - var_dump($tabtype[$key]); - var_dump($tabbq[$key]);*/ + //var_dump($tabpay[$key]); + //var_dump($tabtype[$key]); + //var_dump($tabbq[$key]); //print ''.$langs->trans("ThirdpartyAccountNotDefined").''; if (!empty($tabcompany[$key]['code_compta'])) { if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 7cc7f0effbc..426bc6d7795 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -418,9 +418,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; - if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + } else { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + } } else { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -897,12 +902,12 @@ if (empty($action) || $action == 'view') { print ""; // Subledger account print "'; $companystatic->id = $tabcompany[$key]['id']; diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index 0d95ff61763..49b4fc2c98c 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -43,17 +43,6 @@ if ($in_bookkeeping == '') { $in_bookkeeping = 'notyet'; } -// Security check -if (empty($conf->accounting->enabled)) { - accessforbidden(); -} -if ($user->socid > 0) { - accessforbidden(); -} -if (empty($user->rights->accounting->mouvements->lire)) { - accessforbidden(); -} - // Get information of journal $object = new AccountingJournal($db); $result = $object->fetch($id_journal); @@ -65,7 +54,7 @@ if ($result > 0) { accessforbidden($langs->trans('ErrorRecordNotFound')); } -$hookmanager->initHooks(array('globaljournal', $object->nature_text . 'journal')); +$hookmanager->initHooks(array('globaljournal', $object->nature.'journal')); $parameters = array(); $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); @@ -93,6 +82,18 @@ if (!is_array($journal_data)) { setEventMessages($object->error, $object->errors, 'errors'); } +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->socid > 0) { + accessforbidden(); +} +if (empty($user->rights->accounting->mouvements->lire)) { + accessforbidden(); +} + + /* * Actions */ diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index e46b508512d..d350e2243a2 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -38,7 +38,7 @@ $validatemonth = GETPOST('validatemonth', 'int'); $validateyear = GETPOST('validateyear', 'int'); // Security check -if (empty($conf->accounting->enabled)) { +if (!isModEnabled('accounting')) { accessforbidden(); } if ($user->socid > 0) { @@ -75,7 +75,7 @@ $action = GETPOST('action', 'aZ09'); $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); // Security check -if (empty($conf->accounting->enabled)) { +if (!isModEnabled('accounting')) { accessforbidden(); } if ($user->socid > 0) { diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 914c6fa1633..32e939f7bee 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,8 +1,9 @@ - * Copyright (C) 2013-2022 Alexandre Spangaro - * Copyright (C) 2014-2015 Ari Elbaz (elarifr) - * Copyright (C) 2013-2014 Florian Henry +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) + * Copyright (C) 2013-2021 Florian Henry + * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2014 Juanjo Menent s * Copyright (C) 2016 Laurent Destailleur * @@ -47,6 +48,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); +$default_account = GETPOST('default_account', 'int'); // Select Box $mesCasesCochees = GETPOST('toselect', 'array'); @@ -442,12 +444,15 @@ if ($result) { $arrayofmassactions = array( 'ventil'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate") + ,'set_default_account'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount") //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + if ($massaction !== 'set_default_account') { + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + } print ''."\n"; print ''; @@ -462,6 +467,14 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + if ($massaction == 'set_default_account') { + $formquestion[]=array('type' => 'other', + 'name' => 'set_default_account', + 'label' => $langs->trans("AccountancyCode"), + 'value' => $formaccounting->select_account('', 'default_account', 1, array(), 0, 0, 'maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone')); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($toselect)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); + } + print ''.$langs->trans("DescVentilTodoCustomer").'

'; if ($msg) { @@ -736,7 +749,7 @@ if ($result) { // Suggested accounting account print '
'; // Column with checkbox @@ -745,6 +758,14 @@ if ($result) { if (!empty($suggestedid) && $suggestedaccountingaccountfor != '' && $suggestedaccountingaccountfor != 'eecwithoutvatnumber') { $ischecked = 1; } + + if (!empty($toselect)) { + $ischecked = 0; + if (in_array($objp->rowid."_".$i, $toselect)) { + $ischecked=1; + } + } + print ''; print ''; diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index d51dd8ef730..80092ea96a5 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -64,7 +64,7 @@ if ($action == 'set_default') { } elseif ($action == 'del_default') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->MEMBER_ADDON_PDF_ODT == "$value") { + if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == "$value") { dolibarr_del_const($db, 'MEMBER_ADDON_PDF_ODT', $conf->entity); } } @@ -108,7 +108,7 @@ if ($action == 'set_default') { $res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); // Use vat for invoice creation - if ($conf->facture->enabled) { + if (isModEnabled('facture')) { $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { @@ -241,22 +241,22 @@ $arraychoices = array('0'=>$langs->trans("None")); if (!empty($conf->banque->enabled)) { $arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect"); } -if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { +if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) { $arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly"); } -if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { +if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) { $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice"); } print ''; print "\n"; // Use vat for invoice creation -if ($conf->facture->enabled) { +if (isModEnabled('facture')) { print ''; if (!empty($conf->banque->enabled)) { print ''; } else { print '"; } // Defaut print ''; @@ -398,8 +398,8 @@ foreach ($dirmodels as $reldir) { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn(!empty($module->option_logo) ? $module->option_logo : 0, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn(!empty($module->option_multilang) ? $module->option_multilang : 0, 1, 1); print ''; } @@ -1224,7 +1224,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; + print ''; } // Morphy $morphys["phy"] = $langs->trans("Physical"); @@ -1286,7 +1286,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // EMail - print ''; + print ''; print ''; // Website @@ -2030,7 +2030,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $MAX = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index cafc9338ae8..3f857ce827b 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -121,6 +121,9 @@ class AdherentType extends CommonObject /** @var array Array of members */ public $members = array(); + /** @var string string other */ + public $other = array(); + public $multilangs = array(); diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 9aef78174de..b3cfe027197 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -490,17 +490,17 @@ class Subscription extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; $sql .= ' WHERE c.rowid = '.((int) $id); - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); } - $this->db->free($result); + $this->db->free($resql); } else { dol_print_error($this->db); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 2b0c295afbd..1ef98dddb6d 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -99,12 +99,12 @@ $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members per type", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $adhtype = new AdherentType($db); $adhtype->id = $objp->rowid; @@ -127,7 +127,7 @@ if ($result) { $i++; } - $db->free($result); + $db->free($resql); } $now = dol_now(); @@ -143,16 +143,16 @@ $sql .= " AND t.rowid = d.fk_adherent_type"; $sql .= " GROUP BY d.fk_adherent_type"; dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; } - $db->free(); + $db->free($resql); } /* diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c2ef4583bdc..8bf7f7af6a6 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2018 Alexandre Spangaro @@ -63,6 +63,7 @@ $search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); $search_filter = GETPOST("search_filter", 'alpha'); $search_status = GETPOST("search_status", 'intcomma'); +$search_import_key = trim(GETPOST("search_import_key", "alpha")); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); @@ -156,7 +157,8 @@ $arrayfields = array( 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'd.birth'=>array('label'=>$langs->trans("Birthday"), 'checked'=>0, 'position'=>500), 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) + 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -213,6 +215,7 @@ if (empty($reshook)) { $search_categ = ""; $search_filter = ""; $search_status = ""; + $search_import_key = ''; $catid = ""; $sall = ""; $toselect = array(); @@ -305,6 +308,8 @@ $formother = new FormOther($db); $membertypestatic = new AdherentType($db); $memberstatic = new Adherent($db); +$title = $langs->trans("Members"); + $now = dol_now(); if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { @@ -316,7 +321,7 @@ $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,"; $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; -$sql .= " d.note_private, d.note_public,"; +$sql .= " d.note_private, d.note_public, d.import_key,"; $sql .= " s.nom,"; $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,"; $sql .= " t.libelle as type, t.subscription,"; @@ -425,6 +430,9 @@ if ($search_phone_mobile) { if ($search_country) { $sql .= " AND d.country IN (".$db->sanitize($search_country).')'; } +if ($search_import_key) { + $sql .= natural_search("d.import_key", $search_import_key); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -434,8 +442,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -445,15 +451,20 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } else { dol_print_error($db); } + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); +} + +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } -// Add limit -$sql .= $db->plimit($limit + 1, $offset); -dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -462,6 +473,7 @@ if (!$resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { @@ -471,42 +483,42 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +llxHeader('', $title, $help_url); -$titre = $langs->trans("MembersList"); if (GETPOSTISSET("search_status")) { if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED - $titre = $langs->trans("MembersListQualified"); + $title = $langs->trans("MembersListQualified"); } if ($search_status == Adherent::STATUS_DRAFT) { - $titre = $langs->trans("MembersListToValid"); + $title = $langs->trans("MembersListToValid"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') { - $titre = $langs->trans("MenuMembersValidated"); + $title = $langs->trans("MenuMembersValidated"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') { - $titre = $langs->trans("MembersWithSubscriptionToReceive"); + $title = $langs->trans("MembersWithSubscriptionToReceive"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'uptodate') { - $titre = $langs->trans("MembersListUpToDate"); + $title = $langs->trans("MembersListUpToDate"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'outofdate') { - $titre = $langs->trans("MembersListNotUpToDate"); + $title = $langs->trans("MembersListNotUpToDate"); } if ((string) $search_status == (string) Adherent::STATUS_RESILIATED) { // The cast to string is required to have test false when search_status is '' - $titre = $langs->trans("MembersListResiliated"); + $title = $langs->trans("MembersListResiliated"); } if ($search_status == Adherent::STATUS_EXCLUDED) { - $titre = $langs->trans("MembersListExcluded"); + $title = $langs->trans("MembersListExcluded"); } } elseif ($action == 'search') { - $titre = $langs->trans("MembersListQualified"); + $title = $langs->trans("MembersListQualified"); } if ($search_type > 0) { $membertype = new AdherentType($db); $result = $membertype->fetch($search_type); - $titre .= " (".$membertype->label.")"; + $title .= " (".$membertype->label.")"; } $param = ''; @@ -576,6 +588,9 @@ if ($search_filter && $search_filter != '-1') { if ($search_status != "" && $search_status != -3) { $param .= "&search_status=".urlencode($search_status); } +if ($search_import_key != '') { + $param .= '&search_import_key='.urlencode($search_import_key); +} if ($search_type > 0) { $param .= "&search_type=".urlencode($search_type); } @@ -602,7 +617,7 @@ if ($user->rights->societe->creer) { if ($user->rights->adherent->creer && $user->rights->user->user->creer) { $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); } -if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -623,7 +638,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "member"; @@ -668,7 +683,6 @@ if ($massactionbutton) { print '
'; print '
'; print $langs->trans('Docdate'); print '
'.$langs->trans("DateExport").''; @@ -548,7 +548,7 @@ if ($action == 'create') { print '
'.$langs->trans("DateValidation").''; @@ -607,6 +607,7 @@ if ($action == 'create') { print '
'; $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { @@ -647,11 +648,14 @@ if ($action == 'create') { print "
'; - print $formaccounting->select_account($suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account(($default_account > 0 && $confirm === 'yes' && in_array($objp->rowid."_".$i, $toselect)) ? $default_account : $suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print '"; - if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { - if (($accountoshow == "") || $accountoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - } else { + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { print length_accounta($tabcompany[$key]['code_compta']); } + } elseif (($accountoshow == "") || $accountoshow == 'NotDefined') { + print '' . $langs->trans("ThirdpartyAccountNotDefined") . ''; } print ''; - print $formaccounting->select_account($suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account(($default_account > 0 && $confirm === 'yes' && in_array($objp->rowid."_".$i, $toselect)) ? $default_account : $suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; -print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); -if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') { +print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, getDolGlobalString('ADHERENT_BANK_USE'), 0); +if (getDolGlobalString('ADHERENT_BANK_USE') == 'bankdirect' || getDolGlobalString('ADHERENT_BANK_USE') == 'bankviainvoice') { print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; } print '
'.$langs->trans("VATToUseForSubscriptions").''; @@ -378,16 +378,16 @@ foreach ($dirmodels as $reldir) { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; - if ($conf->global->MEMBER_ADDON_PDF == $name) { + if (getDolGlobalString('MEMBER_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) ? $module->scandir : '').'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; diff --git a/htdocs/adherents/admin/member_extrafields.php b/htdocs/adherents/admin/member_extrafields.php index 7f5262bc7c6..210e6213d6f 100644 --- a/htdocs/adherents/admin/member_extrafields.php +++ b/htdocs/adherents/admin/member_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/adherents/admin/member_type_extrafields.php b/htdocs/adherents/admin/member_type_extrafields.php index 68916df624f..c643d6e15d4 100644 --- a/htdocs/adherents/admin/member_type_extrafields.php +++ b/htdocs/adherents/admin/member_type_extrafields.php @@ -87,7 +87,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index ed09c206abf..6199991f29c 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -95,12 +95,13 @@ if ($action == 'update') { $form = new Form($db); +$title = $langs->trans("MembersSetup"); $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; -llxHeader('', $langs->trans("MembersSetup"), $help_url); +llxHeader('', $title, $help_url); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); +print load_fiche_titre($title, $linkback, 'title_setup'); $head = member_admin_prepare_head(); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 9132dae5802..5aeb3a281cf 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -162,11 +162,11 @@ if ($object->id > 0) { $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + if (isModEnabled('agenda')) { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).($object->id > 0 ? '?id='.$object->id : '').'&origin=member&originid='.$id); } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; $param = '&id='.$id; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5bdb99330f6..d7e46749de3 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -285,7 +285,7 @@ if (empty($reshook)) { $object->lastname = trim(GETPOST("lastname", 'alphanohtml')); $object->gender = trim(GETPOST("gender", 'alphanohtml')); $object->login = trim(GETPOST("login", 'alphanohtml')); - $object->pass = trim(GETPOST("pass", 'alpha')); + $object->pass = trim(GETPOST("pass", 'none')); // For password, we must use 'none' $object->societe = trim(GETPOST("societe", 'alphanohtml')); // deprecated $object->company = trim(GETPOST("societe", 'alphanohtml')); @@ -450,8 +450,8 @@ if (empty($reshook)) { $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $login = GETPOST("member_login", 'alphanohtml'); - $pass = GETPOST("password", 'alpha'); - $photo = GETPOST("photo", 'alpha'); + $pass = GETPOST("password", 'none'); // For password, we use 'none' + $photo = GETPOST("photo", 'alphanohtml'); $morphy = GETPOST("morphy", 'alphanohtml'); $public = GETPOST("public", 'alphanohtml'); @@ -999,7 +999,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password = getRandomPassword(false); print '
'.$langs->trans("Password").''; - print ''; + print ''; print '
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Password").'pass).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').'
'.(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '' : '').$langs->trans("EMail").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '' : '').''.img_picto('', 'object_email', 'class="pictofixedwidth"').'email).'">
'."\n"; - // Line for filters fields print ''; @@ -806,15 +820,24 @@ if (!empty($arrayfields['d.statut']['checked'])) { print $form->selectarray('search_status', $liststatus, $search_status, -3); print ''; } -// Action column -print ''; - +if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; +} +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + // Action column + print ''; +} print "\n"; print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); +} if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); } @@ -894,7 +917,12 @@ if (!empty($arrayfields['d.tms']['checked'])) { if (!empty($arrayfields['d.statut']['checked'])) { print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +if (!empty($arrayfields['d.import_key']['checked'])) { + print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +} print "\n"; $i = 0; @@ -935,7 +963,7 @@ while ($i < min($num, $limit)) { print ''; if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -1171,21 +1199,31 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - // Action column - print '\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!$i) { $totalarray['nbfield']++; } - print "\n"; + print ''."\n"; $i++; } diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php index 160a037c187..a01e7d28ed2 100644 --- a/htdocs/adherents/partnership.php +++ b/htdocs/adherents/partnership.php @@ -85,11 +85,18 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'member') accessforbidden(); -if (empty($conf->partnership->enabled)) accessforbidden(); -if (empty($permissiontoread)) accessforbidden(); -if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); - +if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') { + accessforbidden('Partnership module is not activated for members'); +} +if (empty($conf->partnership->enabled)) { + accessforbidden(); +} +if (empty($permissiontoread)) { + accessforbidden(); +} +if ($action == 'edit' && empty($permissiontoadd)) { + accessforbidden(); +} if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) { accessforbidden(); } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 7dccaa90eda..cf0ad445c92 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -831,11 +831,11 @@ if ($rowid > 0) { $bankviainvoice = 1; } } else { - if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) { $bankviainvoice = 1; } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) { $bankdirect = 1; - } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) { $invoiceonly = 1; } } @@ -982,7 +982,7 @@ if ($rowid > 0) { print '">'; // Complementary action - if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { + if ((!empty($conf->banque->enabled) || isModEnabled('facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { $company = new Societe($db); if ($object->fk_soc) { $result = $company->fetch($object->fk_soc); @@ -1003,7 +1003,7 @@ if ($rowid > 0) { print '>
'; } // Add invoice with no payments - if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + if (!empty($conf->societe->enabled) && isModEnabled('facture')) { print 'fk_soc)) print ' disabled'; print '>
'; } // Add invoice with payments - if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) { print 'fk_soc)) print ' disabled'; print '>\n"; // Payment mode print '\n"; // Date of payment diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index d96adbc3b82..6056e1320f0 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -628,10 +628,10 @@ while ($i < min($num, $limit)) { print ''; if (!$i) { diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 693170862e9..c6d321707dc 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -53,18 +53,18 @@ if ($reshook < 0) { if (($action == 'update' && !GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) { - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOST("state_id", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOST("state_id", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", GETPOST('country_id', 'int'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("tel", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("tel", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity); if ($action != 'updateedit' && !$error) { @@ -119,17 +119,17 @@ print ''."\n"; +print 'global->MAIN_INFO_ACCOUNTANT_NAME) ? ' autofocus="autofocus"' : '').'>'."\n"; // Address print ''."\n"; +print ''."\n"; print ''."\n"; +print ''."\n"; print ''."\n"; +print ''."\n"; // Country print ''."\n"; print ''."\n"; print ''; +print ''; print ''."\n"; print ''; +print ''; print ''."\n"; print ''; +print ''; print ''."\n"; // Web print ''; +print ''; print ''."\n"; // Code print ''."\n"; +print ''."\n"; // Note print '"; // Active if ($conf->global->BANK_COLORIZE_MOVEMENT) { print ''; } else { print '"; } @@ -483,13 +473,13 @@ print ''; // Active if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { print ''; } else { print '"; } diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 35fd9f5271f..1382ef49983 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -85,7 +85,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index e3adb206d7e..dc56d3ae79f 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -93,7 +93,7 @@ if ($action == 'updateMask') { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf"); return; } else { - setEventMessages($module->error, null, 'errors'); + setEventMessages($module->error, $module->errors, 'errors'); dol_syslog($module->error, LOG_ERR); } } else { @@ -176,7 +176,7 @@ $head = bomAdminPrepareHead(); print dol_get_fiche_head($head, 'settings', $langs->trans("BOMs"), -1, 'bom'); /* - * BOMs Numbering model + * Numbering module */ print load_fiche_titre($langs->trans("BOMsNumberingModules"), '', ''); @@ -202,10 +202,11 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle)) !== false) { if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); + $classname = $file; require_once $dir.$file.'.php'; - $module = new $file($db); + $module = new $classname($db); // Show modules according to features level if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { @@ -220,7 +221,7 @@ foreach ($dirmodels as $reldir) { print $module->info(); print ''; - // Show example of numbering model + // Show example of numbering module print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + print ''; + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'.$obj->rowid.''.$obj->rowid.''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; + print dol_escape_htmltag($obj->import_key); + print "'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("FinancialAccount").''; print img_picto('', 'bank_account'); - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200'); print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200'); print "
'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { + if (in_array($obj->crowid, $arrayofselected)) { $selected = 1; } - print ''; + print ''; } print '
'.$langs-> // Name print '
'; -print 'global->MAIN_INFO_ACCOUNTANT_NAME) ? ' autofocus="autofocus"' : '').'>
'; -print '
'; -print '
'; -print '
'; @@ -142,33 +142,33 @@ print '
'; print img_picto('', 'state', 'class="pictofixedwidth"'); -print $formcompany->select_state((GETPOSTISSET('state_id') ? GETPOST('state_id', 'alpha') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_STATE) ? $conf->global->MAIN_INFO_ACCOUNTANT_STATE : '')), (GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'state_id'); +print $formcompany->select_state((GETPOSTISSET('state_id') ? GETPOST('state_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_STATE) ? $conf->global->MAIN_INFO_ACCOUNTANT_STATE : '')), (GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'state_id'); print '
'; print img_picto('', 'object_phoning', '', false, 0, 0, '', 'pictofixedwidth'); -print '
'; print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'pictofixedwidth'); -print '
'; print img_picto('', 'object_email', '', false, 0, 0, '', 'pictofixedwidth'); -print '
'; print img_picto('', 'globe', '', false, 0, 0, '', 'pictofixedwidth'); -print '
'; -print '
'; diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index af09d32bc73..52926cf1b19 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -173,6 +173,9 @@ if (!empty($triggers)) { if ($module == 'contact') { $module = 'societe'; } + if ($module == 'facturerec') { + $module = 'facture'; + } // If 'element' value is myobject@mymodule instead of mymodule $tmparray = explode('@', $module); diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 50e4a3e92c7..13f8ad246a0 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -89,7 +89,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index e1e468b0cec..ef365881feb 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -53,8 +53,6 @@ $type = 'bankaccount'; // Order display of bank account if ($action == 'setbankorder') { if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } @@ -63,15 +61,11 @@ if ($action == 'setbankorder') { // Auto report last num releve on conciliate if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } } elseif ($action == 'unsetreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } @@ -80,15 +74,11 @@ if ($action == 'setreportlastnumreleve') { // Colorize movements if ($action == 'setbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } } elseif ($action == 'unsetbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } @@ -427,13 +417,13 @@ print "'."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { @@ -277,13 +278,13 @@ foreach ($dirmodels as $reldir) { } print "
"; print ""; -print "
\n"; /* * Document templates generators */ +print "
\n"; print load_fiche_titre($langs->trans("BOMsModelModule"), '', ''); // Load array def with activated templates @@ -307,8 +308,8 @@ if ($resql) { print '
'; -print "\n"; -print "\n"; +print '
'; +print ''; print ''; print ''; print '\n"; @@ -364,13 +365,13 @@ foreach ($dirmodels as $reldir) { // Active if (in_array($name, $def)) { print ''; } else { print '"; } @@ -379,7 +380,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->BOM_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 ''; @@ -421,12 +422,12 @@ foreach ($dirmodels as $reldir) { print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'."\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 "
"; /* * Other options */ +print "
"; print load_fiche_titre($langs->trans("OtherOptions"), '', ''); print '
'; diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index 74d6ca931ec..c8ebafd4be8 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 6c3a6f30646..1bc5f67239e 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -229,6 +229,7 @@ $sql .= " WHERE b.box_id = bd.rowid"; $sql .= " AND b.entity IN (0,".$conf->entity.")"; $sql .= " AND b.fk_user=0"; $sql .= " ORDER by b.position, b.box_order"; +//print $sql; dol_syslog("Search available boxes", LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php index ac8f4fced4d..cf887b6b454 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php @@ -94,7 +94,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index c3cb92dba8d..86800eea947 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -91,9 +91,9 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) $db->begin(); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency", 'aZ09'), 'chaine', 0, '', $conf->entity); @@ -178,19 +178,19 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) } } - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'nohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object", 'nohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START", 'int'), 'chaine', 0, '', $conf->entity); @@ -403,18 +403,18 @@ print '
'.$langs-> // Name print '
'; -print 'global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '').'>
'; -print '
'; -print '
'; -print '
'; @@ -564,17 +564,17 @@ $langs->load("companies"); // Managing Director(s) print '
'; -print '
'; print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc")); print ''; -print 'global->MAIN_INFO_GDPR) ? $conf->global->MAIN_INFO_GDPR : ''))).'">
'; -print '
'; diff --git a/htdocs/admin/delivery_extrafields.php b/htdocs/admin/delivery_extrafields.php index cf712bc6ecf..fa1aa809944 100644 --- a/htdocs/admin/delivery_extrafields.php +++ b/htdocs/admin/delivery_extrafields.php @@ -91,7 +91,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/deliverydet_extrafields.php b/htdocs/admin/deliverydet_extrafields.php index c74f5235d42..6fbfbb58884 100644 --- a/htdocs/admin/deliverydet_extrafields.php +++ b/htdocs/admin/deliverydet_extrafields.php @@ -92,7 +92,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 70768b1cf3f..6453210e596 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -104,50 +104,50 @@ $taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, // Name of SQL tables of dictionaries $tabname = array(); -$tabname[1] = MAIN_DB_PREFIX."c_forme_juridique"; -$tabname[2] = MAIN_DB_PREFIX."c_departements"; -$tabname[3] = MAIN_DB_PREFIX."c_regions"; -$tabname[4] = MAIN_DB_PREFIX."c_country"; -$tabname[5] = MAIN_DB_PREFIX."c_civility"; -$tabname[6] = MAIN_DB_PREFIX."c_actioncomm"; -$tabname[7] = MAIN_DB_PREFIX."c_chargesociales"; -$tabname[8] = MAIN_DB_PREFIX."c_typent"; -$tabname[9] = MAIN_DB_PREFIX."c_currencies"; -$tabname[10] = MAIN_DB_PREFIX."c_tva"; -$tabname[11] = MAIN_DB_PREFIX."c_type_contact"; -$tabname[12] = MAIN_DB_PREFIX."c_payment_term"; -$tabname[13] = MAIN_DB_PREFIX."c_paiement"; -$tabname[14] = MAIN_DB_PREFIX."c_ecotaxe"; -$tabname[15] = MAIN_DB_PREFIX."c_paper_format"; -$tabname[16] = MAIN_DB_PREFIX."c_prospectlevel"; -$tabname[17] = MAIN_DB_PREFIX."c_type_fees"; -$tabname[18] = MAIN_DB_PREFIX."c_shipment_mode"; -$tabname[19] = MAIN_DB_PREFIX."c_effectif"; -$tabname[20] = MAIN_DB_PREFIX."c_input_method"; -$tabname[21] = MAIN_DB_PREFIX."c_availability"; -$tabname[22] = MAIN_DB_PREFIX."c_input_reason"; -$tabname[23] = MAIN_DB_PREFIX."c_revenuestamp"; -$tabname[24] = MAIN_DB_PREFIX."c_type_resource"; -$tabname[25] = MAIN_DB_PREFIX."c_type_container"; -//$tabname[26]= MAIN_DB_PREFIX."c_units"; -$tabname[27] = MAIN_DB_PREFIX."c_stcomm"; -$tabname[28] = MAIN_DB_PREFIX."c_holiday_types"; -$tabname[29] = MAIN_DB_PREFIX."c_lead_status"; -$tabname[30] = MAIN_DB_PREFIX."c_format_cards"; -//$tabname[31]= MAIN_DB_PREFIX."accounting_system"; -$tabname[32] = MAIN_DB_PREFIX."c_hrm_public_holiday"; -$tabname[33] = MAIN_DB_PREFIX."c_hrm_department"; -$tabname[34] = MAIN_DB_PREFIX."c_hrm_function"; -$tabname[35] = MAIN_DB_PREFIX."c_exp_tax_cat"; -$tabname[36] = MAIN_DB_PREFIX."c_exp_tax_range"; -$tabname[37] = MAIN_DB_PREFIX."c_units"; -$tabname[38] = MAIN_DB_PREFIX."c_socialnetworks"; -$tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel"; -$tabname[40] = MAIN_DB_PREFIX."c_stcommcontact"; -$tabname[41] = MAIN_DB_PREFIX."c_transport_mode"; -$tabname[42] = MAIN_DB_PREFIX."c_product_nature"; -$tabname[43] = MAIN_DB_PREFIX."c_productbatch_qcstatus"; -$tabname[44] = MAIN_DB_PREFIX."c_asset_disposal_type"; +$tabname[1] = "c_forme_juridique"; +$tabname[2] = "c_departements"; +$tabname[3] = "c_regions"; +$tabname[4] = "c_country"; +$tabname[5] = "c_civility"; +$tabname[6] = "c_actioncomm"; +$tabname[7] = "c_chargesociales"; +$tabname[8] = "c_typent"; +$tabname[9] = "c_currencies"; +$tabname[10] = "c_tva"; +$tabname[11] = "c_type_contact"; +$tabname[12] = "c_payment_term"; +$tabname[13] = "c_paiement"; +$tabname[14] = "c_ecotaxe"; +$tabname[15] = "c_paper_format"; +$tabname[16] = "c_prospectlevel"; +$tabname[17] = "c_type_fees"; +$tabname[18] = "c_shipment_mode"; +$tabname[19] = "c_effectif"; +$tabname[20] = "c_input_method"; +$tabname[21] = "c_availability"; +$tabname[22] = "c_input_reason"; +$tabname[23] = "c_revenuestamp"; +$tabname[24] = "c_type_resource"; +$tabname[25] = "c_type_container"; +//$tabname[26]= "c_units"; +$tabname[27] = "c_stcomm"; +$tabname[28] = "c_holiday_types"; +$tabname[29] = "c_lead_status"; +$tabname[30] = "c_format_cards"; +//$tabname[31]= "accounting_system"; +$tabname[32] = "c_hrm_public_holiday"; +$tabname[33] = "c_hrm_department"; +$tabname[34] = "c_hrm_function"; +$tabname[35] = "c_exp_tax_cat"; +$tabname[36] = "c_exp_tax_range"; +$tabname[37] = "c_units"; +$tabname[38] = "c_socialnetworks"; +$tabname[39] = "c_prospectcontactlevel"; +$tabname[40] = "c_stcommcontact"; +$tabname[41] = "c_transport_mode"; +$tabname[42] = "c_product_nature"; +$tabname[43] = "c_productbatch_qcstatus"; +$tabname[44] = "c_asset_disposal_type"; // Dictionary labels $tablib = array(); @@ -225,7 +225,7 @@ $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFI $tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity = ".getEntity($tabname[25]); //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm"; -$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; +$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.sortorder, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; @@ -265,14 +265,14 @@ $tabsqlsort[17] = "code ASC"; $tabsqlsort[18] = "code ASC, libelle ASC"; $tabsqlsort[19] = "id ASC"; $tabsqlsort[20] = "code ASC, libelle ASC"; -$tabsqlsort[21] = "code ASC, label ASC, position ASC, type_duration ASC, qty ASC"; +$tabsqlsort[21] = "position ASC, type_duration ASC, qty ASC"; $tabsqlsort[22] = "code ASC, label ASC"; $tabsqlsort[23] = "country ASC, taux ASC"; $tabsqlsort[24] = "code ASC, label ASC"; $tabsqlsort[25] = "t.module ASC, t.code ASC, t.label ASC"; //$tabsqlsort[26]="code ASC"; $tabsqlsort[27] = "code ASC"; -$tabsqlsort[28] = "country ASC, code ASC"; +$tabsqlsort[28] = "sortorder ASC, country ASC, code ASC"; $tabsqlsort[29] = "position ASC"; $tabsqlsort[30] = "code ASC"; //$tabsqlsort[31]="pcg_version ASC"; @@ -319,7 +319,7 @@ $tabfield[24] = "code,label"; $tabfield[25] = "code,label"; //$tabfield[26]= "code,label,short_label"; $tabfield[27] = "code,libelle,picto"; -$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative"; +$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative,sortorder"; $tabfield[29] = "code,label,percent,position"; $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfield[31]= "pcg_version,label"; @@ -366,7 +366,7 @@ $tabfieldvalue[24] = "code,label"; $tabfieldvalue[25] = "code,label"; //$tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27] = "code,libelle,picto"; -$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative"; +$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative,sortorder"; $tabfieldvalue[29] = "code,label,percent,position"; $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldvalue[31]= "pcg_version,label"; @@ -413,7 +413,7 @@ $tabfieldinsert[24] = "code,label"; $tabfieldinsert[25] = "code,label"; //$tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27] = "code,libelle,picto"; -$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative"; +$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative,sortorder"; $tabfieldinsert[29] = "code,label,percent,position"; $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldinsert[31]= "pcg_version,label"; @@ -488,14 +488,14 @@ $tabcond[2] = true; $tabcond[3] = true; $tabcond[4] = true; $tabcond[5] = (!empty($conf->societe->enabled) || !empty($conf->adherent->enabled)); -$tabcond[6] = !empty($conf->agenda->enabled); +$tabcond[6] = isModEnabled('agenda'); $tabcond[7] = !empty($conf->tax->enabled); $tabcond[8] = !empty($conf->societe->enabled); $tabcond[9] = true; $tabcond[10] = true; $tabcond[11] = (!empty($conf->societe->enabled)); -$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled)); -$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled)); +$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || isModEnabled('facture') || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled)); +$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || isModEnabled('facture') || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled)); $tabcond[14] = (!empty($conf->product->enabled) && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); $tabcond[15] = true; $tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); @@ -508,12 +508,12 @@ $tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enable $tabcond[23] = true; $tabcond[24] = !empty($conf->resource->enabled); $tabcond[25] = !empty($conf->website->enabled); -//$tabcond[26]= ! empty($conf->product->enabled); +//$tabcond[26]= !empty($conf->product->enabled); $tabcond[27] = !empty($conf->societe->enabled); $tabcond[28] = !empty($conf->holiday->enabled); -$tabcond[29] = !empty($conf->projet->enabled); +$tabcond[29] = !empty($conf->project->enabled); $tabcond[30] = !empty($conf->label->enabled); -//$tabcond[31]= ! empty($conf->accounting->enabled); +//$tabcond[31]= !empty($conf->accounting->enabled); $tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled)); $tabcond[33] = !empty($conf->hrm->enabled); $tabcond[34] = !empty($conf->hrm->enabled); @@ -528,112 +528,94 @@ $tabcond[42] = !empty($conf->product->enabled); $tabcond[43] = !empty($conf->product->enabled) && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2; $tabcond[44] = !empty($conf->asset->enabled); -// List of help for fields +// List of help for fields (no more used, help is defined into tabcomplete) $tabhelp = array(); -$tabhelp[1] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[2] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[3] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[4] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[5] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[6] = array('code'=>$langs->trans("EnterAnyCode"), 'color'=>$langs->trans("ColorFormat"), 'position'=>$langs->trans("PositionIntoComboList")); -$tabhelp[7] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[8] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList")); -$tabhelp[9] = array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency")); -$tabhelp[10] = array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc")); -$tabhelp[11] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList")); -$tabhelp[12] = array('code'=>$langs->trans("EnterAnyCode"), 'type_cdr'=>$langs->trans("TypeCdr", $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"), $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"))); -$tabhelp[13] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[14] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[15] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[16] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[17] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[18] = array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc")); -$tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList")); -$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent'); -$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode')); -//$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp")); -$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); -$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList")); -$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize")); -//$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); -$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'dayrule'=>"Keep empty for a date defined with month and day (most common case).
Use a keyword like 'easter', 'eastermonday', ... for a date predefined by complex rules.", 'country'=>$langs->trans("CountryIfSpecificToOneCountry"), 'year'=>$langs->trans("ZeroMeansEveryYear")); -$tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[35] = array(); -$tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange')); -$tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('Measuringtype_durationDesc'), 'scale' => $langs->trans('MeasuringScaleDesc')); -$tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc')); -$tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp")); -$tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[43] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[44] = array('code'=>$langs->trans("EnterAnyCode")); // Table to store complete informations (will replace all other table). Key is table name. $tabcomplete = array( - 'c_forme_juridique'=>array('picto'=>'company'), - 'c_departements'=>array('picto'=>'state'), - 'c_regions'=>array('picto'=>'region'), - 'c_country'=>array('picto'=>'country'), - 'c_civility'=>array('picto'=>'contact'), - 'c_actioncomm'=>array('picto'=>'action'), - 'c_chargesociales'=>array('picto'=>'bill'), - 'c_typent'=>array('picto'=>'company'), - 'c_currencies'=>array('picto'=>'multicurrency'), - 'c_tva'=>array('picto'=>'bill'), - 'c_type_contact'=>array('picto'=>'contact'), - 'c_payment_term'=>array('picto'=>'bill'), - 'c_paiement'=>array('picto'=>'bill'), - 'c_ecotaxe'=>array('picto'=>'bill'), - 'c_paper_format'=>array('picto'=>'generic'), - 'c_prospectlevel'=>array('picto'=>'company'), - 'c_type_fees'=>array('picto'=>'trip'), - 'c_effectif'=>array('picto'=>'company'), - 'c_input_method'=>array('picto'=>'order'), - 'c_input_reason'=>array('picto'=>'order'), - 'c_availability'=>array('picto'=>'shipment'), - 'c_shipment_mode'=>array('picto'=>'shipment'), - 'c_revenuestamp'=>array('picto'=>'bill'), - 'c_type_resource'=>array('picto'=>'resource'), - 'c_type_container'=>array('picto'=>'website'), - 'c_stcomm'=>array('picto'=>'company'), - 'c_holiday_types'=>array('picto'=>'holiday'), - 'c_lead_status'=>array('picto'=>'project'), - 'c_format_cards'=>array('picto'=>'generic'), - 'c_hrm_public_holiday'=>array('picto'=>'holiday'), - 'c_hrm_department'=>array('picto'=>'hrm'), - 'c_hrm_function'=>array('picto'=>'hrm'), - 'c_exp_tax_cat'=>array('picto'=>'expensereport'), - 'c_exp_tax_range'=>array('picto'=>'expensereport'), - 'c_units'=>array('picto'=>'product'), - 'c_socialnetworks'=>array('picto'=>'share-alt'), - 'c_product_nature'=>array('picto'=>'product'), - 'c_transport_mode'=>array('picto'=>'incoterm'), - 'c_prospectcontactlevel'=>array('picto'=>'company'), - 'c_stcommcontact'=>array('picto'=>'company'), - 'c_product_nature'=>array('picto'=>'product'), - 'c_productbatch_qcstatus'=>array('picto'=>'lot'), - 'c_asset_disposal_type'=>array('picto'=>'asset'), - + 'c_forme_juridique'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_departements'=>array('picto'=>'state', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_regions'=>array('picto'=>'region', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_country'=>array('picto'=>'country', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_civility'=>array('picto'=>'contact', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_actioncomm'=>array('picto'=>'action', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'color'=>$langs->trans("ColorFormat"), 'position'=>$langs->trans("PositionIntoComboList"))), + 'c_chargesociales'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_typent'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"))), + 'c_currencies'=>array('picto'=>'multicurrency', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency"))), + 'c_tva'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc"))), + 'c_type_contact'=>array('picto'=>'contact', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"))), + 'c_payment_term'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'type_cdr'=>$langs->trans("TypeCdr", $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"), $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset")))), + 'c_paiement'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_ecotaxe'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_paper_format'=>array('picto'=>'generic', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_prospectlevel'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_type_fees'=>array('picto'=>'trip', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_shipment_mode'=>array('picto'=>'shipment', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc"))), + 'c_effectif'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_input_method'=>array('picto'=>'order', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_input_reason'=>array('picto'=>'order', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"))), + 'c_availability'=>array('picto'=>'shipment', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_revenuestamp'=>array('picto'=>'bill', 'help'=>array('revenuestamp_type'=>$langs->trans('FixedOrPercent'))), + 'c_type_resource'=>array('picto'=>'resource', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_type_container'=>array('picto'=>'website', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_stcomm'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"))), + 'c_holiday_types'=>array('picto'=>'holiday', 'help'=>array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"))), + 'c_lead_status'=>array('picto'=>'project', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"))), + 'c_format_cards'=>array('picto'=>'generic', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"))), + 'c_hrm_public_holiday'=>array('picto'=>'holiday', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'dayrule'=>"Keep empty for a date defined with month and day (most common case).
Use a keyword like 'easter', 'eastermonday', ... for a date predefined by complex rules.", 'country'=>$langs->trans("CountryIfSpecificToOneCountry"), 'year'=>$langs->trans("ZeroMeansEveryYear"))), + 'c_hrm_department'=>array('picto'=>'hrm', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_hrm_function'=>array('picto'=>'hrm', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_exp_tax_cat'=>array('picto'=>'expensereport', 'help'=>array()), + 'c_exp_tax_range'=>array('picto'=>'expensereport', 'help'=>array('range_ik'=>$langs->trans('PrevRangeToThisRange'))), + 'c_units'=>array('picto'=>'product', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('Measuringtype_durationDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'))), + 'c_socialnetworks'=>array('picto'=>'share-alt', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'))), + 'c_prospectcontactlevel'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_stcommcontact'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"))), + 'c_transport_mode'=>array('picto'=>'incoterm', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_product_nature'=>array('picto'=>'product', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_productbatch_qcstatus'=>array('picto'=>'lot', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_asset_disposal_type'=>array('picto'=>'asset', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), ); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabcomplete); +// Complete the table $tabcomplete +$i = 0; +foreach ($tabcomplete as $key => $value) { + $i++; + // When a dictionnary is commented + if (!isset($tabcond[$i])) { + continue; + } + $tabcomplete[$key]['id'] = $i; + $tabcomplete[$key]['cond'] = $tabcond[$i]; + $tabcomplete[$key]['rowid'] = $tabrowid[$i]; + $tabcomplete[$key]['fieldinsert'] = $tabfieldinsert[$i]; + $tabcomplete[$key]['fieldvalue'] = $tabfieldvalue[$i]; + $tabcomplete[$key]['lib'] = $tablib[$i]; + $tabcomplete[$key]['sql'] = $tabsql[$i]; + $tabcomplete[$key]['sqlsort'] = $tabsqlsort[$i]; + $tabcomplete[$key]['field'] = $tabfield[$i]; +} + +$keytable = ''; +if ($id > 0) { + $arrayofkeys = array_keys($tabcomplete); + $keytable = $arrayofkeys[$id - 1]; +} + // Defaut sortorder if (empty($sortfield)) { - $tmp1 = explode(',', empty($tabsqlsort[$id]) ? '' : $tabsqlsort[$id]); + $tmp1 = explode(',', empty($tabcomplete[$keytable]['sqlsort']) ? '' : $tabcomplete[$keytable]['sqlsort']); $tmp2 = explode(' ', $tmp1[0]); $sortfield = preg_replace('/^.*\./', '', $tmp2[0]); + $sortorder = (!empty($tmp2[1]) ? $tmp2[1] : ''); + //var_dump($sortfield);var_dump($sortorder); } + // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); $sourceList = array(); @@ -675,25 +657,22 @@ if ($id == 11) { } // Define localtax_typeList (used for dictionary "llx_c_tva") -$localtax_typeList = array(); -if ($id == 10) { - $localtax_typeList = array( - "0" => $langs->trans("No"), - "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), - "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), - "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), - "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), - "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), - "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"), - ); -} - +$localtax_typeList = array( + "0" => $langs->trans("No"), + "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), + "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), + "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), + "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), + "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), + "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"), +); /* * Actions */ +$object = new stdClass(); $parameters = array( 'id' =>$id, 'rowid' =>$rowid, @@ -820,11 +799,11 @@ if (empty($reshook)) { $fieldnamekey = 'UseByDefault'; } - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } // Other checks - if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) { + if (GETPOST('actionadd') && $tabname[$id] == "c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) { $ok = 0; setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); } @@ -867,12 +846,15 @@ if (empty($reshook)) { $_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', GETPOST("code")); } + $tablename = $tabname[$id]; + $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename); + // If check ok and action add, add the line if ($ok && GETPOST('actionadd')) { if ($tabrowid[$id]) { // Get free id for insert $newid = 0; - $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; + $sql = "SELECT MAX(".$tabrowid[$id].") as newid FROM ".MAIN_DB_PREFIX.$tablename; $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); @@ -883,7 +865,7 @@ if (empty($reshook)) { } // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$tablename." ("; // List of fields if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) { $sql .= $tabrowid[$id].","; @@ -908,7 +890,7 @@ if (empty($reshook)) { } elseif ($value == 'taux' || $value == 'localtax1') { $_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z } elseif ($value == 'entity') { - $_POST[$keycode] = getEntity($tabname[$id]); + $_POST[$keycode] = getEntity($tablename); } if ($i) { @@ -924,7 +906,7 @@ if (empty($reshook)) { } elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'"; } $i++; @@ -959,7 +941,7 @@ if (empty($reshook)) { } // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; + $sql = "UPDATE ".MAIN_DB_PREFIX.$tablename." SET "; // Modifie valeur des champs if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) { $sql .= $tabrowid[$id]."="; @@ -977,7 +959,7 @@ if (empty($reshook)) { } elseif ($field == 'taux' || $field == 'localtax1') { $_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z } elseif ($field == 'entity') { - $_POST[$keycode] = getEntity($tabname[$id]); + $_POST[$keycode] = getEntity($tablename); } if ($i) { @@ -993,7 +975,7 @@ if (empty($reshook)) { } elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'"; } $i++; @@ -1004,7 +986,7 @@ if (empty($reshook)) { $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); } if (in_array('entity', $listfieldmodify)) { - $sql .= " AND entity = ".((int) getEntity($tabname[$id], 0)); + $sql .= " AND entity = ".((int) getEntity($tablename, 0)); } dol_syslog("actionmodify", LOG_DEBUG); @@ -1014,11 +996,6 @@ if (empty($reshook)) { setEventMessages($db->error(), null, 'errors'); } } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition - } - - if (GETPOST('actioncancel')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete @@ -1028,7 +1005,10 @@ if (empty($reshook)) { $rowidcol = "rowid"; } - $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $tablename = $tabname[$id]; + $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -1050,9 +1030,9 @@ if (empty($reshook)) { } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -1070,9 +1050,9 @@ if (empty($reshook)) { } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -1090,9 +1070,9 @@ if (empty($reshook)) { } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -1110,9 +1090,9 @@ if (empty($reshook)) { } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -1130,9 +1110,9 @@ if (empty($reshook)) { } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -1150,9 +1130,9 @@ if (empty($reshook)) { } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -1228,7 +1208,7 @@ if ($action == 'delete') { /* * Show a dictionary */ -if ($id) { +if ($id > 0) { // Complete search values request with sort criteria $sql = $tabsql[$id]; @@ -1296,6 +1276,7 @@ if ($id) { print ''; // Line for title + print ''; $tdsoffields = ''; foreach ($fieldlist as $field => $value) { if ($value == 'entity') { @@ -1318,7 +1299,7 @@ if ($id) { $valuetoshow = $langs->trans("PriceUHT"); } if ($value == 'taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { + if ($tabname[$id] != "c_revenuestamp") { $valuetoshow = $langs->trans("Rate"); } else { $valuetoshow = $langs->trans("Amount"); @@ -1344,7 +1325,7 @@ if ($id) { $valuetoshow = $langs->trans("Language"); } if ($value == 'type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") { + if ($tabname[$id] == "c_paiement") { $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); } else { $valuetoshow = $langs->trans("Type"); @@ -1374,12 +1355,14 @@ if ($id) { } if ($value == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); + $class = 'right'; } if ($value == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; } if ($value == 'decalage') { $valuetoshow = $langs->trans("Offset"); + $class = 'right'; } if ($value == 'width' || $value == 'nx') { $valuetoshow = $langs->trans("Width"); @@ -1416,6 +1399,7 @@ if ($id) { } if ($value == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); + $class = 'center'; } if ($value == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); @@ -1512,37 +1496,39 @@ if ($id) { } if ($valuetoshow != '') { - $tdsoffields .= ''; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { - $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif (!empty($tabhelp[$id][$value])) { - $tdsoffields .= $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); + + $tdsoffields .= ''; + if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { + $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif ($tooltiphelp) { + $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp); } else { $tdsoffields .= $valuetoshow; } - $tdsoffields .= ''; + $tdsoffields .= ''; } } if ($id == 4) { - $tdsoffields .= ''; - $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; } - $tdsoffields .= ''; - $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; $tdsoffields .= ''; print $tdsoffields; // Line to enter new values - print ''; + print ''; print ''; $obj = new stdClass(); @@ -1613,6 +1599,7 @@ if ($id) { print '
'; + $tdsoffields .= ''; $tdsoffields .= ''; if (!is_null($withentity)) { $tdsoffields .= ''; } - $tdsoffields .= ''; - $tdsoffields .= '
'; // Title line with search input fields + print ''."\n"; print ''; $filterfound = 0; foreach ($fieldlist as $field => $value) { @@ -1657,14 +1644,15 @@ if ($id) { print ''; // Title of lines + print ''."\n"; print ''; foreach ($fieldlist as $field => $value) { if ($value == 'entity') { continue; } - if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabhelp[$id][$value])) { - $tabhelp[$id][$value] = $langs->trans('LabelUsedByDefault'); + if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabcomplete[$tabname[$id]]['help'][$value])) { + $tabcomplete[$tabname[$id]]['help'][$value] = $langs->trans('LabelUsedByDefault'); } // Determines the name of the field in relation to the possible names @@ -1683,7 +1671,7 @@ if ($id) { $valuetoshow = $langs->trans("PriceUHT"); } if ($value == 'taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { + if ($tabname[$id] != "c_revenuestamp") { $valuetoshow = $langs->trans("Rate"); } else { $valuetoshow = $langs->trans("Amount"); @@ -1736,12 +1724,14 @@ if ($id) { } if ($value == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); + $cssprefix = 'right '; } if ($value == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $cssprefix = "center "; } if ($value == 'decalage') { $valuetoshow = $langs->trans("Offset"); + $cssprefix = 'right '; } if ($value == 'width' || $value == 'nx') { $valuetoshow = $langs->trans("Width"); @@ -1775,6 +1765,7 @@ if ($id) { } if ($value == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); + $cssprefix = 'center '; } if ($value == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); @@ -1867,10 +1858,12 @@ if ($id) { // Show field title if ($showfield) { - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { - $newvaluetoshow = ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif (!empty($tabhelp[$id][$value])) { - $newvaluetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); + + if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { + $newvaluetoshow = ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif ($tooltiphelp) { + $newvaluetoshow = $form->textwithpicto($valuetoshow, $tooltiphelp); } else { $newvaluetoshow = $valuetoshow; } @@ -1973,58 +1966,58 @@ if ($id) { $key = $langs->trans("PaymentCondition".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$value}); $valuetoshow = nl2br($valuetoshow); - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + } elseif ($value == 'label' && $tabname[$id] == 'c_country') { $key = $langs->trans("Country".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { + } elseif ($value == 'label' && $tabname[$id] == 'c_availability') { $langs->load("propal"); $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') { $key = $langs->trans("Action".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_currencies') { + } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') { $key = $langs->trans("Currency".strtoupper($obj->code_iso)); $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_typent') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') { $key = $langs->trans(strtoupper($obj->code)); $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_prospectlevel') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') { $key = $langs->trans(strtoupper($obj->code)); $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_civility') { + } elseif ($value == 'label' && $tabname[$id] == 'c_civility') { $key = $langs->trans("Civility".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_contact') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') { $langs->load('agenda'); $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_payment_term') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') { $langs->load("bills"); $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') { $langs->load("bills"); $key = $langs->trans("PaymentType".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'type' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') { + } elseif ($value == 'type' && $tabname[$id] == 'c_paiement') { $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); $valuetoshow = $payment_type_list[$valuetoshow]; - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_reason') { + } elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') { $key = $langs->trans("DemandReasonType".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_method') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') { $langs->load("orders"); $key = $langs->trans($obj->code); $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$value}; - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_shipment_mode') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') { $langs->load("sendings"); $key = $langs->trans("SendingMethod".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paper_format') { + } elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$value}); - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') { + } elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$value}); @@ -2032,13 +2025,13 @@ if ($id) { $showfield = 0; } elseif ($value == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); - } elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') { + } elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$value}); - } elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') { + } elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$value}); - } elseif (($value == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) { + } elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$value}); } elseif ($value == 'localtax1' || $value == 'localtax2') { @@ -2079,20 +2072,20 @@ if ($id) { } } elseif ($value == 'fk_c_exp_tax_cat') { $tmpid = $valuetoshow; - $valuetoshow = getDictionaryValue(MAIN_DB_PREFIX.'c_exp_tax_cat', 'label', $tmpid); + $valuetoshow = getDictionaryValue('c_exp_tax_cat', 'label', $tmpid); $valuetoshow = $langs->trans($valuetoshow ? $valuetoshow : $tmpid); - } elseif ($tabname[$id] == MAIN_DB_PREFIX.'c_exp_tax_cat') { + } elseif ($tabname[$id] == 'c_exp_tax_cat') { $valuetoshow = $langs->trans($valuetoshow); - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_units') { + } elseif ($value == 'label' && $tabname[$id] == 'c_units') { $langs->load('other'); $key = $langs->trans($obj->label); $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$value}); } elseif ($value == 'code' && $id == 3) { $valuetoshow = $obj->state_code; - } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_product_nature') { + } elseif ($value == 'label' && $tabname[$id] == 'c_product_nature') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$value}); - } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') { + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == 'c_productbatch_qcstatus') { $langs->load("productbatch"); $valuetoshow = $langs->trans($obj->{$value}); } elseif ($value == 'block_if_negative') { @@ -2108,13 +2101,13 @@ if ($id) { if ($value == 'tracking') { $class .= ' tdoverflowauto'; } - if (in_array($value, array('pos', 'position', 'deposit_percent'))) { + if (in_array($value, array('nbjour', 'decalage', 'pos', 'position', 'deposit_percent'))) { $class .= ' right'; } if (in_array($value, array('localtax1_type', 'localtax2_type'))) { $class .= ' nowrap'; } - if (in_array($value, array('use_default', 'fk_parent'))) { + if (in_array($value, array('use_default', 'fk_parent', 'sortorder'))) { $class .= ' center'; } if ($value == 'public') { @@ -2158,7 +2151,7 @@ if ($id) { if (!empty($obj->code) && $obj->code == 'RECEP') { $canbemodified = 1; } - if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") { + if ($tabname[$id] == "c_actioncomm") { $canbemodified = 1; } @@ -2185,7 +2178,7 @@ if ($id) { if ($iserasable) { print ''.$actl[$obj->eec].''; } else { - print $langs->trans("AlwaysActive"); + print ''.$langs->trans("AlwaysActive").''; } print ''; print ''; } @@ -2210,7 +2203,7 @@ if ($id) { } elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') { print $langs->trans("UsedOnlyWithTypeOption"); } else { - print $langs->trans("AlwaysActive"); + print ''.$langs->trans("AlwaysActive").''; } } print ""; @@ -2294,7 +2287,7 @@ if ($id) { print ''; print ''; print ''; print ''; $lastlineisempty = false; @@ -2344,7 +2337,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') continue; } - if (in_array($value, array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) { + if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) { $hidden = (!empty($obj->{$value}) ? $obj->{$value}:''); print ''; - } elseif ($value == 'element') { - // The type of the element (for contact types) + } elseif (in_array($value, array('element', 'source'))) { //Example: the type and source of the element (for contact types) print ''; - } elseif ($value == 'source') { - // The source of the element (for contact types) - print ''; } elseif (in_array($value, array('public', 'use_default'))) { // Fields 0/1 with a combo select Yes/No @@ -2400,12 +2387,12 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; - } elseif ($value == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") { + } elseif ($value == 'type' && $tabname == "c_actioncomm") { $type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module) print ''; - } elseif ($value == 'type' && $tabname == MAIN_DB_PREFIX.'c_paiement') { + } elseif ($value == 'type' && $tabname == 'c_paiement') { print ''; } elseif (in_array($value, array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) { - $class = "left"; + $class = "right"; if (in_array($value, array('taux', 'localtax1', 'localtax2'))) { $class = "center"; // Fields aligned on right } @@ -2435,7 +2422,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $transfound = 0; $transkey = ''; // Special case for labels - if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { + if ($tabname == 'c_payment_term') { $langs->load("bills"); $transkey = "PaymentCondition".strtoupper($obj->code); if ($langs->trans($transkey) != $transkey) { @@ -2501,18 +2488,21 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } else { $fieldValue = isset($obj->{$value}) ? $obj->{$value}: ''; + $classtd = ''; $class = ''; if ($value == 'sortorder') { $fieldlist[$field] = 'position'; } - $classtd = ''; $class = ''; if ($fieldlist[$field] == 'code') { $class = 'maxwidth100'; } - if (in_array($fieldlist[$field], array('pos', 'position', 'deposit_percent'))) { + if (in_array($fieldlist[$field], array('deposit_percent'))) { $classtd = 'right'; $class = 'maxwidth50 right'; } + if (in_array($fieldlist[$field], array('pos', 'position'))) { + $classtd = 'center'; $class = 'maxwidth50 center'; + } if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'use_default', 'affect', 'delay', 'public', 'sortorder', 'sens', 'category_type', 'fk_parent'))) { $class = 'maxwidth50 center'; } @@ -2533,19 +2523,19 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $maxlength = ''; if (in_array($fieldlist[$field], array('libelle', 'label'))) { switch ($tabname) { - case MAIN_DB_PREFIX . 'c_accounting_category': - case MAIN_DB_PREFIX . 'c_ecotaxe': - case MAIN_DB_PREFIX . 'c_email_senderprofile': - case MAIN_DB_PREFIX . 'c_forme_juridique': - case MAIN_DB_PREFIX . 'c_holiday_types': - case MAIN_DB_PREFIX . 'c_payment_term': - case MAIN_DB_PREFIX . 'c_transport_mode': + case 'c_accounting_category': + case 'c_ecotaxe': + case 'c_email_senderprofile': + case 'c_forme_juridique': + case 'c_holiday_types': + case 'c_payment_term': + case 'c_transport_mode': $maxlength = ' maxlength="255"'; break; - case MAIN_DB_PREFIX . 'c_email_templates': + case 'c_email_templates': $maxlength = ' maxlength="180"'; break; - case MAIN_DB_PREFIX . 'c_socialnetworks': + case 'c_socialnetworks': $maxlength = ' maxlength="150"'; break; default: @@ -2558,10 +2548,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $transkey = ''; if (in_array($fieldlist[$field], array('label', 'libelle'))) { // For label // Special case for labels - if ($tabname == MAIN_DB_PREFIX.'c_civility' && !empty($obj->code)) { + if ($tabname == 'c_civility' && !empty($obj->code)) { $transkey = "Civility".strtoupper($obj->code); } - if ($tabname == MAIN_DB_PREFIX.'c_payment_term' && !empty($obj->code)) { + if ($tabname == 'c_payment_term' && !empty($obj->code)) { $langs->load("bills"); $transkey = "PaymentConditionShort".strtoupper($obj->code); } diff --git a/htdocs/admin/ecm_directories_extrafields.php b/htdocs/admin/ecm_directories_extrafields.php index d913826b245..ea75c5ea0fc 100644 --- a/htdocs/admin/ecm_directories_extrafields.php +++ b/htdocs/admin/ecm_directories_extrafields.php @@ -91,7 +91,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/ecm_files_extrafields.php b/htdocs/admin/ecm_files_extrafields.php index b260eff55fa..41a0d714eb9 100644 --- a/htdocs/admin/ecm_files_extrafields.php +++ b/htdocs/admin/ecm_files_extrafields.php @@ -91,7 +91,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index d01b160ca31..ab4f0c7def0 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Charlene 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 @@ -359,47 +360,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->emailcollector->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->emailcollector->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->emailcollector->creer) - { - if ($action != 'classify') - { - $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); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } - } - */ $morehtmlref .= '
'; $morehtml = $langs->trans("NbOfEmailsInInbox").' : '; @@ -561,7 +521,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $rulefilterobj->fetch($rulefilter['id']); print '
'; - print ''; print ''; @@ -583,24 +543,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; print ''; - // Add operation - print ''; - print ''; + print ''; - print ''."\n"; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { print ''; echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -266,11 +280,11 @@ foreach ($rules as $rule) { if ($rule->fk_c_type_fees == -1) { echo $langs->trans('AllExpenseReport'); } else { - $key = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); + $key = getDictionaryValue('c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); if ($key && $key != $langs->trans($key)) { echo $langs->trans($key); } else { - $value = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id'); + $value = getDictionaryValue('c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id'); echo $langs->trans($value ? $value : 'Undefined'); // TODO check to return trans of 'code' } } @@ -304,10 +318,10 @@ foreach ($rules as $rule) { } echo ''; - + // Amount echo ''; print ''; print "\n"; -/*var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); -*/ +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); + if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) { $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1; } if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) { $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1; } -/* -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); -*/ + +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); + // Set working days print ''; diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index 609187058e3..0ef1998d9e7 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -85,7 +85,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index bf486ea3d4e..d3afd4035e4 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -76,7 +76,7 @@ if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) { } if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $logofile = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND; @@ -99,11 +99,19 @@ if ($action == 'update') { $error = 0; if ($mode == 'template') { - dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); + //dolibarr_del_const($db, "MAIN_THEME", 0); // To be sure we don't have this constant set for all entities - /*$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);*/ + dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); + + if (GETPOSTISSET('THEME_TOPMENU_DISABLE_IMAGE')) { + $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 == '') { @@ -222,7 +230,7 @@ if ($action == 'update') { 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_IHM_PARAMS_REV", getDolGlobalInt('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); @@ -323,130 +331,6 @@ print '
'; clearstatcache(); -if ($mode == 'template') { - // Themes and themes options - showSkins(null, 1); -} - -if ($mode == 'dashboard') { - print '
'; - print '
'; @@ -2193,7 +2186,7 @@ if ($id) { if ($iserasable) { print ''.$actl[$obj->favorite].''; } else { - print $langs->trans("AlwaysActive"); + print ''.$langs->trans("AlwaysActive").''; } print ''; - print $form->textwithpicto('', $langs->trans("Table").': '.$tabname[$i]); + print $form->textwithpicto('', $langs->trans("Table").': '.MAIN_DB_PREFIX.$tabname[$i]); print '
'; print ''; @@ -2380,15 +2373,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang'); print ''; - print $form->selectarray('element', $elementList, (!empty($obj->{$value}) ? $obj->{$value}:'')); - print ''; - print $form->selectarray('source', $sourceList, (!empty($obj->{$value}) ? $obj->{$value}:'')); + print $form->selectarray($value, $elementList, (!empty($obj->{$value}) ? $obj->{$value}:'')); print ''; print $form->selectyesno("private", (!empty($obj->{$value}) ? $obj->{$value}:'')); print ''; print $type.''; print ''; $select_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); print $form->selectarray($value, $select_list, (!empty($obj->{$value}) ? $obj->{$value}:'2')); @@ -2423,7 +2410,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } print '
'; + print ''; print $langs->trans($arrayoftypes[$rulefilter['type']]['label']); print ''.$rulefilter['rulevalue'].'
'.img_picto('', 'technic', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("EmailcollectorOperations"), $langs->trans("EmailcollectorOperationsDesc")).'
'; + $arrayoftypes = array( 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), 'recordjoinpiece'=>'AttachJoinedDocumentsToObject', 'recordevent'=>'RecordEvent'); $arrayoftypesnocondition = $arrayoftypes; - if ($conf->projet->enabled) { + if (!empty($conf->project->enabled)) { $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; } $arrayoftypesnocondition['project'] = 'CreateLeadAndThirdParty'; - if ($conf->ticket->enabled) { + if (!empty($conf->ticket->enabled)) { $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; } $arrayoftypesnocondition['ticket'] = 'CreateTicketAndThirdParty'; - if ($conf->recruitment->enabled) { + if (!empty($conf->recruitment->enabled)) { $arrayoftypes['candidature'] = 'CreateCandidature'; } $arrayoftypesnocondition['candidature'] = 'CreateCandidature'; @@ -617,6 +575,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } + // Add operation + print '
'; print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1); print ''; print ''; @@ -637,7 +598,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $ruleactionobj->fetch($ruleaction['id']); print '
'; + print ''; print ''; if (array_key_exists($ruleaction['type'], $arrayoftypes)) { print $langs->trans($arrayoftypes[$ruleaction['type']]); diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 32b55d0a612..6a980642c5f 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -205,7 +205,7 @@ $form = new Form($db); $now = dol_now(); $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector"; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); +$title = $langs->trans('EmailCollectors'); $morejs = array(); $morecss = array(); @@ -279,7 +279,7 @@ foreach ($object->fields as $key => $val) { $sql .= "t.".$db->escape($key).", "; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { +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.', ' : ''); } @@ -420,7 +420,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table diff --git a/htdocs/admin/eventorganization_confbooth_extrafields.php b/htdocs/admin/eventorganization_confbooth_extrafields.php index 991ed3f824a..f17a2cf91e1 100644 --- a/htdocs/admin/eventorganization_confbooth_extrafields.php +++ b/htdocs/admin/eventorganization_confbooth_extrafields.php @@ -81,7 +81,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/eventorganization_confboothattendee_extrafields.php b/htdocs/admin/eventorganization_confboothattendee_extrafields.php index 0b50c483d69..552e814f8de 100644 --- a/htdocs/admin/eventorganization_confboothattendee_extrafields.php +++ b/htdocs/admin/eventorganization_confboothattendee_extrafields.php @@ -85,7 +85,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index b76ee35b76c..948efb6188a 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -91,7 +91,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 4f807ee9da3..41fba691b7f 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -92,7 +92,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index fc63940f0b8..e5169ce55cc 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -148,7 +148,7 @@ if ($action == 'updateMask') { $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res3 = 0; - if (!empty($conf->projet->enabled) && GETPOSTISSET('EXPENSEREPORT_PROJECT_IS_REQUIRED')) { // Option may not be provided + if (!empty($conf->project->enabled) && GETPOSTISSET('EXPENSEREPORT_PROJECT_IS_REQUIRED')) { // Option may not be provided $res3 = dolibarr_set_const($db, 'EXPENSEREPORT_PROJECT_IS_REQUIRED', GETPOST('EXPENSEREPORT_PROJECT_IS_REQUIRED', 'int'), 'chaine', 0, '', $conf->entity); } @@ -471,7 +471,7 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htm print ''; print '
'; print $langs->trans('ProjectIsRequiredOnExpenseReports'); print ''; diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 25771ef63d0..54ce5a9ffea 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -85,7 +85,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index 900754ef4b4..10b14f8ee99 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -36,10 +36,10 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); $error = 0; $action = GETPOST('action', 'aZ09'); + $id = GETPOST('id', 'int'); $ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); - $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_range = GETPOST('fk_range', 'int'); @@ -62,9 +62,16 @@ if ($action == 'updateik') { } } - $expIk->setValues($_POST); - $result = $expIk->create($user); + $expIk->coef = $coef; + $expIk->ikoffset = $ikoffset; + $expIk->fk_c_exp_tax_cat = $fk_c_exp_tax_cat; + $expIk->fk_range = $fk_range; + if ($expIk->id > 0) { + $result = $expIk->update($user); + } else { + $result = $expIk->create($user); + } if ($result > 0) { setEventMessages('SetupSaved', null, 'mesgs'); diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 1146232dca3..7c27ee6e408 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -34,13 +34,19 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.ph // Load translation files required by the page $langs->loadLangs(array("admin", "other", "trips", "errors", "dict")); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admin', 'dictionaryadmin','expensereport_rules')); + +$object = new ExpenseReportRule($db); + if (!$user->admin) { accessforbidden(); } -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admin', 'dictionaryadmin','expensereport_rules')); +/* + * Action + */ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -51,7 +57,6 @@ if ($reshook < 0) { if (empty($reshook)) { //Init error $error = false; - $message = false; $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -59,21 +64,20 @@ if (empty($reshook)) { $apply_to = GETPOST('apply_to'); $fk_user = GETPOST('fk_user', 'int'); $fk_usergroup = GETPOST('fk_usergroup', 'int'); - - $fk_c_type_fees = GETPOST('fk_c_type_fees'); + $restrictive = GETPOST('restrictive', 'int'); + $fk_c_type_fees = GETPOST('fk_c_type_fees', 'int'); $code_expense_rules_type = GETPOST('code_expense_rules_type'); $dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear')); $datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - $amount = GETPOST('amount'); + $amount = price2num(GETPOST('amount'), 'MT', 2); - $object = new ExpenseReportRule($db); if (!empty($id)) { $result = $object->fetch($id); if ($result < 0) { dol_print_error('', $object->error, $object->errors); } } - // TODO do action + if ($action == 'save') { $error = 0; @@ -104,8 +108,6 @@ if (empty($reshook)) { } if (empty($error)) { - $object->setValues($_POST); - if ($apply_to == 'U') { $object->fk_user = (int) $fk_user; $object->fk_usergroup = 0; @@ -122,18 +124,30 @@ if (empty($reshook)) { $object->dates = $dates; $object->datee = $datee; - + $object->restrictive = $restrictive; + $object->fk_c_type_fees = $fk_c_type_fees; + $object->code_expense_rules_type = $code_expense_rules_type; + $object->amount = $amount; $object->entity = $conf->entity; - $res = $object->create($user); + if ($object->id > 0) { + $res = $object->update($user); + } else { + $res = $object->create($user); + } if ($res > 0) { setEventMessages($langs->trans('ExpenseReportRuleSave'), null); } else { dol_print_error($object->db); + $error++; } - header('Location: ' . $_SERVER['PHP_SELF']); - exit; + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF']); + exit; + } else { + $action = ''; + } } } elseif ($action == 'delete') { // TODO add confirm @@ -207,7 +221,7 @@ if ($action != 'edit') { echo '' . $form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0) . '' . $form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0) . ' ' . $conf->currency . '' . $form->selectyesno('restrictive', 0, 1) . '
'; if ($action == 'edit' && $object->id == $rule->id) { - echo '' . $conf->currency; + echo ''; } else { echo price($rule->amount, 0, $langs, 1, -1, -1, $conf->currency); } diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 140cd7fcfdf..3ea92bb48ad 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -63,10 +63,10 @@ $conditions = array( 'NOTE_PRIVATE' => 1, 'SOCIETE' => 1, 'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)), - 'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), + 'DETAILS' => (isModEnabled('facture') || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), 'USERSIGN' => 1, 'MAILING' => !empty($conf->mailing->enabled), - 'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)), + 'MAIL' => (isModEnabled('facture') || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)), 'TICKET' => !empty($conf->ticket->enabled), ); // Picto diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index c1755b17edf..7b0aa577a87 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -442,23 +442,23 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - - // Message of the day on home page - $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); - complete_substitutions_array($substitutionarray, $langs); - - print '' . "\n"; - - /* no more need for this option. It is now a widget already controlled by end user - print ''; - print ''; - */ - - print '
'; - $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '
'; - foreach ($substitutionarray as $key => $val) { - $texthelp .= $key . '
'; - } - 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 '
'; -} - if ($mode == 'other') { print '
'; print ''; @@ -587,6 +471,133 @@ if ($mode == 'other') { print ''; } + +if ($mode == 'template') { + // Themes and themes options + showSkins(null, 1); +} + + +if ($mode == 'dashboard') { + print '
'; + print '
'; + + // Message of the day on home page + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); + complete_substitutions_array($substitutionarray, $langs); + + print '' . "\n"; + + /* no more need for this option. It is now a widget already controlled by end user + print ''; + print ''; + */ + + print '
'; + $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '
'; + foreach ($substitutionarray as $key => $val) { + $texthelp .= $key . '
'; + } + 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 '
'; +} + + if ($mode == 'login') { // Other print '
'; diff --git a/htdocs/admin/knowledgerecord_extrafields.php b/htdocs/admin/knowledgerecord_extrafields.php index d6c94e4ceeb..62580d585c3 100644 --- a/htdocs/admin/knowledgerecord_extrafields.php +++ b/htdocs/admin/knowledgerecord_extrafields.php @@ -88,7 +88,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index e122bdf5930..ef488943a4b 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -244,7 +244,7 @@ print '
'.$langs->trans // Pass print ''; print '
'.$langs->trans("LDAPPassword").''; -print ''; +print ''; print ''.$langs->trans('Password').' (ex: secret)
'; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d96e0706223..e01c3142cc0 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -57,6 +57,7 @@ $langs->loadLangs($langsArray); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$mode = GETPOST('mode', 'aZ09'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'alpha'); @@ -168,8 +169,6 @@ $tabhelp[25] = array( ); -$elementList = array(); - // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" $elementList = array(); // Add all and none after the sort @@ -186,7 +185,7 @@ if (!empty($conf->recruitment->enabled) && !empty($user->rights->recruitment->re if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) { $elementList['thirdparty'] = img_picto('', 'company', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToThirdparty')); } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $elementList['project'] = img_picto('', 'project', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToProject')); } if (!empty($conf->propal->enabled) && !empty($user->rights->propal->lire)) { @@ -195,7 +194,7 @@ if (!empty($conf->propal->enabled) && !empty($user->rights->propal->lire)) { if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) { $elementList['order_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendOrder')); } -if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { +if (isModEnabled('facture') && !empty($user->rights->facture->lire)) { $elementList['facture_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendInvoice')); } if (!empty($conf->expedition->enabled)) { @@ -225,7 +224,7 @@ if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) { if (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire)) { $elementList['expensereport_send'] = img_picto('', 'trip', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTExpenseReport')); } -if (!empty($conf->agenda->enabled)) { +if (isModEnabled('agenda')) { $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush')); } if (!empty($conf->eventorganization->enabled) && !empty($user->rights->eventorganization->read)) { @@ -404,7 +403,7 @@ if (empty($reshook)) { } elseif (in_array($keycode, array('joinfiles', 'private', 'position', 'entity'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'"; } $i++; } @@ -434,7 +433,14 @@ if (empty($reshook)) { // Modifie valeur des champs $i = 0; foreach ($listfieldmodify as $field) { - $keycode = $listfieldvalue[$i]; + if ($field == 'entity') { + // entity not present on listfieldmodify array + $keycode = $field; + $_POST[$keycode] = $conf->entity; + } else { + $keycode = $listfieldvalue[$i]; + } + if ($field == 'lang') { $keycode = 'langcode'; } @@ -458,9 +464,6 @@ if (empty($reshook)) { if ($field == 'content_lines') { $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; } - if ($field == 'entity') { - $_POST[$keycode] = $conf->entity; - } if ($i) { $sql .= ", "; @@ -482,7 +485,7 @@ if (empty($reshook)) { } elseif (in_array($keycode, array('joinfiles', 'private', 'position'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'"; } $i++; @@ -619,15 +622,17 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); +if (!empty($search) && is_array($search)) { + foreach ($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } + } elseif ($search[$key] != '') { + $param .= '&search_'.$key.'='.urlencode($search[$key]); } - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); } } if ($optioncss != '') { diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8ed6615965b..0db1b26dc7d 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -528,8 +528,8 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= ''; //$moreforfilter .= '
'.$moreinfo.' '.$moreinfo2.'
'; diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index d3c03056fef..768ec487165 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print ''.$langs->trans("NewAttribute").''; print "
"; } diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index e11ac077cc6..b66f004295d 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -88,7 +88,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print ''.$langs->trans("NewAttribute").''; print "
"; } diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index c89ff3e3655..3f8102d076a 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -89,7 +89,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print ''.$langs->trans("NewAttribute").''; print "
"; } diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 1e015d69f9c..b95f73a399f 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2012-2107 Juanjo Menent * Copyright (C) 2019 Ferran Marcet - * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2021-2022 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 @@ -108,7 +108,7 @@ if ($action == 'update') { 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 (!empty($conf->project->enabled)) { if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') { dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); @@ -166,6 +166,10 @@ if ($action == 'update') { 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_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) { + dolibarr_set_const($db, "PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", GETPOST('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', '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); } @@ -478,7 +482,7 @@ print ''; // Show project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { print ''.$langs->trans("PDF_SHOW_PROJECT").''; $tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel'); $showprojectref = empty($conf->global->PDF_SHOW_PROJECT) ? (empty($conf->global->PDF_SHOW_PROJECT_TITLE) ? 'no' : 'showprojectlabel') : 'showprojectref'; @@ -564,6 +568,16 @@ print ''.$langs->trans("ShowDetailsInPDFPageFoot").'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 alias in thirdparty name + +/* Disabled because not yet completely implemented (does not work when we force a contact on object) +print ''.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").''; +if ($conf->use_javascript_ajax) { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("THIRDPARTY_ALIAS"), '2' => $langs->trans("ALIAS_THIRDPARTY")); + print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')); +} +*/ + // Show online payment link on invoices print ''.$langs->trans("PDF_SHOW_LINK_TO_ONLINE_PAYMENT").''; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 72acf7fbf4f..d8afe43720f 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -60,6 +60,9 @@ if ($action == 'update') { 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); } + if (GETPOSTISSET('INVOICE_ADD_ZATCA_QR_CODE')) { + dolibarr_set_const($db, "INVOICE_ADD_ZATCA_QR_CODE", GETPOST("INVOICE_ADD_ZATCA_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); + } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -90,19 +93,19 @@ $tooltiptext = ''; print ''.$form->textwithpicto($langs->trans("PDFOtherDesc"), $tooltiptext)."
\n"; print "
\n"; +print '
'; +print ''; +print ''; + if (!empty($conf->propal->enabled)) { print load_fiche_titre($langs->trans("Proposal"), '', ''); - print ''; - print ''; - print ''; - print '
'; print ''; print ''; - print ''; + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"); - print ' ('.$langs->trans("RandomlySelectedIfSeveral").')'; + print '
'; + print $form->textwithpicto($langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), $langs->trans("RandomlySelectedIfSeveral")); print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MAIN_GENERATE_PROPOSALS_WITH_PICTURE'); @@ -112,6 +115,29 @@ if (!empty($conf->propal->enabled)) { } print '
'; + print '
'; +} + + +if (isModEnabled('facture')) { + print load_fiche_titre($langs->trans("Invoices"), '', ''); + + print '
'; + print ''; + print ''; + + print ''; + /* print ''; print ''; print '\n"; print "\n"; // Option to force stock to be enough before adding a line into document -if ($conf->invoice->enabled) { +if (!empty($conf->invoice->enabled)) { print ''; print ''; print '\n"; } -if ($conf->order->enabled) { +if (!empty($conf->order->enabled)) { print ''; print ''; print '\n"; } -if ($conf->expedition->enabled) { +if (!empty($conf->expedition->enabled)) { print ''; print ''; print '\n"; // Ask for payment bank during supplier order /* Kept as hidden for the moment -if ($conf->banque->enabled) -{ +if (isModEnabled('banque')) { print ''; print ''; print ''; print '\n"; print ''; -if ($conf->banque->enabled) { +if (!empty($conf->banque->enabled)) { print '"; print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; +$functions = ["easter_date"]; +$name = "Calendar"; + +print ""; +print ""; +print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); +print ""; + +$functions = ["simplexml_load_string"]; +$name = "Xml"; + +print ""; +print ""; +print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); +print ""; + if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { $functions = ["locale_get_primary_language", "locale_get_region"]; $name = "Intl"; diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php index 8bdca5be40e..4e2f881a14c 100644 --- a/htdocs/admin/system/xcache.php +++ b/htdocs/admin/system/xcache.php @@ -58,23 +58,6 @@ print $langs->trans("xcache.optimizer").': '.yn(ini_get('xcache.optimizer')).' ( print $langs->trans("xcache.stat").': '.yn(ini_get('xcache.stat')).'
'."\n"; print $langs->trans("xcache.coverager").': '.yn(ini_get('xcache.coverager')).'
'."\n"; -//print xcache_get(); -/* -$cacheinfos = array(); -for ($i = 0; $i < 10; $i ++) -{ - $data = xcache_info(XC_TYPE_PHP, $i); - $data['cacheid'] = $i; - $cacheinfos[] = $data; -} - -var_dump($cacheinfos); - -if ($action == 'clear') -{ - xcache_clear_cache(); -} -*/ // End of page llxFooter(); diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f257b040636..f902c3fb39b 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -99,6 +99,50 @@ if ($action == 'updateMask') { // par appel methode canBeActivated dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity); +} elseif ($action == 'setvarworkflow') { + $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (GETPOSTISSET('product_category_id')) { + $param_ticket_product_category = GETPOST('product_category_id', 'int'); + $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + } + + $param_delay_first_response = GETPOST('delay_first_response', 'int'); + $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_delay_between_responses = GETPOST('delay_between_responses', 'int'); + $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } } elseif ($action == 'setvar') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; @@ -146,50 +190,6 @@ if ($action == 'updateMask') { if (!($res > 0)) { $error++; } -} - -if ($action == 'setvarworkflow') { - $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } -} - -if ($action == 'setvarworkflowother' || $action == 'setvarworkflow') { - $param_ticket_product_category = GETPOST('product_category_id', 'int'); - $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } -} - -if ($action == 'setvarother') { - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); @@ -198,34 +198,9 @@ if ($action == 'setvarother') { $error++; } } - - $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_delay_first_response = GETPOST('delay_first_response', 'int'); - $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_delay_between_responses = GETPOST('delay_between_responses', 'int'); - $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } } - /* * View */ @@ -384,8 +359,8 @@ if ($resql) { print '
'; -print "
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans("INVOICE_ADD_ZATCA_QR_CODE"), $langs->trans("INVOICE_ADD_ZATCA_QR_CODEMore")); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVOICE_ADD_ZATCA_QR_CODE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVOICE_ADD_ZATCA_QR_CODE", $arrval, $conf->global->INVOICE_ADD_ZATCA_QR_CODE); + } + print '
'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; if ($conf->use_javascript_ajax) { diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index cb625dbe039..ac136af0c61 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -45,7 +45,7 @@ $printername = GETPOST('printername', 'alpha'); $printerid = GETPOST('printerid', 'int'); $parameter = GETPOST('parameter', 'alpha'); -$template = GETPOST('template', 'nohtml'); +$template = GETPOST('template', 'alphanohtml'); $templatename = GETPOST('templatename', 'alpha'); $templateid = GETPOST('templateid', 'int'); diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index 8e4205a7bdc..aa83fca230c 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -94,7 +94,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index ebd1269f74a..1d3e29c9cd4 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -78,7 +78,7 @@ print '
'; print ''; print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''; @@ -106,6 +106,15 @@ if (empty($conf->use_javascript_ajax)) { print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +/* print ''; print ''; print ''; print ''; print ''; - - -print ''; -print ''; -print ''; -print ''; -print ''; +*/ print '
'.$langs->trans("Parameters").''.$langs->trans("Value").''.$langs->trans("Value").'
'.$langs->trans('EnableResourceUsedInEventCheck').''; +echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK'); +print '
'.$langs->trans('DisabledResourceLinkUser').''; @@ -122,15 +131,7 @@ echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY'); print '
'.$langs->trans('EnableResourceUsedInEventCheck').''; -echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK'); -print '
'; print '
'; diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index c4967f75313..068ae6f02d1 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -74,7 +74,6 @@ llxHeader('', $langs->trans("ResourceSetup")); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ResourceSetup"), $linkback, 'title_setup'); -print "
\n"; $head = resource_admin_prepare_head(); @@ -88,7 +87,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index e8f59727c07..a23f3127ca8 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -209,7 +209,7 @@ $found = 0; print '
'.$langs->trans("DeStockOnBill").''; -if (!empty($conf->facture->enabled)) { +if (isModEnabled('facture')) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); } else { @@ -394,7 +394,7 @@ print "
'.$langs->trans("StockMustBeEnoughForInvoice").''; @@ -408,7 +408,7 @@ if ($conf->invoice->enabled) { print "
'.$langs->trans("StockMustBeEnoughForOrder").''; @@ -422,7 +422,7 @@ if ($conf->order->enabled) { print "
'.$langs->trans("StockMustBeEnoughForShipment").''; diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php new file mode 100644 index 00000000000..541947bf442 --- /dev/null +++ b/htdocs/admin/stocktransfer.php @@ -0,0 +1,484 @@ + + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 SuperAdmin + * + * 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 stocktransfer/admin/setup.php + * \ingroup stocktransfer + * \brief StockTransfer setup page. + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +global $langs, $user; + +// Libraries +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/lib/stocktransfer.lib.php'; + +// Translations +$langs->loadLangs(array("admin", "stocks")); + +// Access control +if (!$user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +$value = GETPOST('value', 'alpha'); + +$arrayofparameters = array( + 'STOCKTRANSFER_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'STOCKTRANSFER_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) +); + +$error = 0; +$setupnotempty = 0; + + +/* + * Actions + */ + +if ((float) DOL_VERSION >= 6) { + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; +} + +if ($action == 'updateMask') { + $maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha'); + $maskstocktransfer = GETPOST('maskStockTransfer', 'alpha'); + + if ($maskconststocktransfer) $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity); + + if (!$res > 0) $error++; + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} elseif ($action == 'specimen') { + $modele = GETPOST('module', 'alpha'); + $tmpobjectkey = 'StockTransfer'; + + $tmpobject = new $tmpobjectkey($db); + $tmpobject->initAsSpecimen(); + + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/stocktransfer/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($tmpobject, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} elseif ($action == 'set') { // Activate a model + $ret = addDocumentModel($value, 'stocktransfer', $label, $scandir); +} elseif ($action == 'del') { + $tmpobjectkey = 'StockTransfer'; + + $ret = delDocumentModel($value, 'stocktransfer'); + if ($ret > 0) { + $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; + if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity); + } +} elseif ($action == 'setdoc') { // Set default model + $tmpobjectkey = 'StockTransfer'; + $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; + if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->$constforval = $value; + } + + // On active le modele + $ret = delDocumentModel($value, 'stocktransfer'); + if ($ret > 0) { + $ret = addDocumentModel($value, 'stocktransfer', $label, $scandir); + } +} elseif ($action == 'setmod') { + // TODO Check if numbering module chosen can be activated + // by calling method canBeActivated + $tmpobjectkey = 'StockTransfer'; + $constforval = 'STOCKTRANSFER_'.strtoupper($tmpobjectkey)."_ADDON"; + dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); +} + + + +/* + * View + */ + +$form = new Form($db); + +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + +$page_name = "StockTransferSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'stock'); + +// Configuration header +$head = stocktransferAdminPrepareHead(); +print dol_get_fiche_head($head, 'settings', '', -1, "stocktransfer@stocktransfer"); + +// Setup page goes here +print ''.$langs->trans("StockTransferSetupPage").''; + + +/*if ($action == 'edit') +{ + print ''; + print ''; + print ''; + + print ''; + print ''; + + foreach ($arrayofparameters as $key => $val) + { + print ''; + } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); + print '
'; + + print '
'; + print ''; + print '
'; + + print ''; + print '
'; +} else { + if (!empty($arrayofparameters)) + { + print ''; + print ''; + + foreach ($arrayofparameters as $key => $val) + { + $setupnotempty++; + + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); + print ''.$conf->global->$key.'
'; + + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; + } + else + { + print '
'.$langs->trans("NothingToSetup"); + } +}*/ + + +$moduledir = 'stocktransfer'; +$myTmpObjects = array(); +$myTmpObjects[$moduledir]=array('includerefgeneration'=>1, 'includedocgeneration'=>1); + +foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { + if ($myTmpObjectKey == 'MyObject') continue; + if ($myTmpObjectArray['includerefgeneration']) { + /* + * Orders Numbering model + */ + $setupnotempty++; + + print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + + clearstatcache(); + + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/".$moduledir); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); + + require_once $dir.'/'.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) { + dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); + + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $mytmpinstance = new $myTmpObjectKey($db); + $mytmpinstance->initAsSpecimen(); + + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + + $nextval = $module->getNextValue($mytmpinstance); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } + } + print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; + print $module->info(); + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + $constforvar = 'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).'_ADDON'; + if ($conf->global->$constforvar == $file) { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

\n"; + } + + if ($myTmpObjectArray['includedocgeneration']) { + /* + * Document templates generators + */ + $setupnotempty++; + $type = strtolower($myTmpObjectKey); + + print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', ''); + + // Load array def with activated templates + $def = array(); + $sql = "SELECT nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE type = '".$db->escape($type)."'"; + $sql .= " AND entity = ".$conf->entity; + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } + } else { + dol_print_error($db); + } + + print "\n"; + print "\n"; + print ''; + print ''; + print '\n"; + print '\n"; + print ''; + print ''; + print "\n"; + + clearstatcache(); + + foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { + $realpath = $reldir."core/modules/".$moduledir.$valdir; + $dir = dol_buildpath($realpath); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); + + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + + if ($modulequalified) { + print ''; + + // Active + if (in_array($name, $def)) { + print ''; + } else { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } + } + + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + 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 "'; + $constforvar = strtoupper($myTmpObjectKey).'_ADDON_PDF'; + if ($conf->global->$constforvar == $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 ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'generic').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; + } +} + +if (empty($setupnotempty)) { + print '
'.$langs->trans("NothingToSetup"); +} + +// Page end +print dol_get_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 0da79845d14..75f2badfda5 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -464,8 +464,7 @@ print "
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '; @@ -521,7 +520,7 @@ print '
'.$langs->trans("UseDispatchStatus").''; -if ($conf->reception->enabled) { +if (isModEnabled('reception')) { print ''.$langs->trans("FeatureNotAvailableWithReceptionModule").''; } else { if ($conf->use_javascript_ajax) { diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 9bd684afb22..80f2c6a62f4 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -498,7 +498,7 @@ print '
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; if (!empty($conf->use_javascript_ajax)) { diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 4121073dec2..6105e6a716b 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -89,7 +89,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 0156eed5072..3bdf8e1e8cc 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -91,7 +91,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 5a49c8f5bfd..e45f8d63cc1 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -89,7 +89,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 07f223d59c8..8fd2516a41d 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -90,7 +90,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 10edae1a24b..58c27cbb1e4 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -407,10 +407,10 @@ if (empty($error) && !empty($xml)) { $checksumget = md5(join(',', $checksumconcat)); $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); - /*var_dump(count($file_list['added'])); - var_dump($checksumget); - var_dump($checksumtoget); - var_dump($checksumget == $checksumtoget);*/ + //var_dump(count($file_list['added'])); + //var_dump($checksumget); + //var_dump($checksumtoget); + //var_dump($checksumget == $checksumtoget); $resultcomment = ''; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index ac51ce33dc3..c9324565e5b 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -183,6 +183,22 @@ print "".$name."
".$name."
".$name."
\n"; -print "\n"; +print '
'."\n"; +print ''."\n"; print ''; print ''; print '\n"; @@ -502,13 +477,14 @@ foreach ($dirmodels as $reldir) { print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."
'; print '

'; -if (empty($conf->use_javascript_ajax)) { - print '
'; - print ''; - print ''; -} + +print ''; +print ''; +print ''; +print ''; print load_fiche_titre($langs->trans("Other"), '', ''); +print '
'; print ''; print ''; @@ -563,34 +539,24 @@ print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp print ''; print ''; -// Choose which product category is used for tickets -if ($conf->use_javascript_ajax) { - print ''; - print ''; - print ''; +if (! empty($conf->product->enabled)) { + print ''; + print ''; + print ''; + print ''; } -print ''; -print ''; -print ''; -print ''; - -// Define wanted maximum time elapsed before answers to tickets -print ''; -print ''; - print ''; print '"; print ''; print ''; print ''; print '"; print ''; print ''; print '
'.$langs->trans("TicketChooseProductCategory").''; + $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); + if ($conf->use_javascript_ajax) { + print ajax_combobox('select_'.$htmlname); + } + print ''; + print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); + print '
'.$langs->trans("TicketChooseProductCategory").''; -$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); -if ($conf->use_javascript_ajax) { - print ajax_combobox('select_'.$htmlname); -} -print ''; -print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); -print '
'.$langs->trans("TicketsDelayBeforeFirstAnswer")." - - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); @@ -600,8 +566,7 @@ print '
'.$langs->trans("TicketsDelayBetweenAnswers")." - - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); @@ -610,9 +575,7 @@ print '

'; -print '
'; -print ''; -print '
'; +print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; @@ -622,9 +585,10 @@ print load_fiche_titre($langs->trans("Notification"), '', ''); print ''; -print ''; +print ''; print ''; print ''; +print ''; print ''; print ''; @@ -699,7 +663,7 @@ print ''; print '
'.$langs->trans("Email").'
'; -print $formcategory->buttonsSaveCancel("Save", ''); +print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index 0a4a851dae2..be75f604542 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -80,7 +80,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 88a7db9b1d7..1a4e3342cd0 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -42,21 +42,24 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; -$error = 0; /* * Actions */ +$error = 0; +$errors = array(); if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { if (GETPOST('value')) { - dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); } else { - dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); } -} - -if ($action == 'setvar') { + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } +} elseif ($action == 'setvar') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; if (GETPOSTISSET('TICKET_ENABLE_PUBLIC_INTERFACE')) { // only for no js case @@ -64,14 +67,7 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; - } - } - - if (GETPOSTISSET('TICKET_EMAIL_MUST_EXISTS')) { // only for no js case - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; + $errors[] = $db->lasterror(); } } @@ -80,6 +76,7 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } } @@ -88,10 +85,11 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } } - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alphanohtml'); if (!empty($topic_interface)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); } else { @@ -99,6 +97,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); @@ -109,6 +108,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); @@ -119,6 +119,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); @@ -129,6 +130,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); @@ -139,12 +141,14 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $param_public_notification_new_message_default_email = GETPOST('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', $param_public_notification_new_message_default_email, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { @@ -152,10 +156,60 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } } +} elseif (preg_match('/set_(.*)/', $action, $reg)) { + $code = $reg[1]; + $value = GETPOSTISSET($code) ? GETPOST($code, 'int') : 1; + $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + + if (!$error) { + if ($code == 'TICKET_EMAIL_MUST_EXISTS') { + $res = dolibarr_del_const($db, 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + } elseif ($code == 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST') { + $res = dolibarr_del_const($db, 'TICKET_EMAIL_MUST_EXISTS', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + + // enable captcha by default + $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA', 1, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + } + } +} elseif (preg_match('/del_(.*)/', $action, $reg)) { + $code = $reg[1]; + $res = dolibarr_del_const($db, $code, $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } } +if ($action != '') { + if (!$error) { + $db->commit(); + setEventMessage($langs->trans('SetupSaved')); + header("Location: " . $_SERVER['PHP_SELF']); + exit; + } else { + $db->rollback(); + setEventMessages('', $errors, 'errors'); + } +} /* @@ -180,7 +234,7 @@ $head = ticketAdminPrepareHead(); print dol_get_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; +print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php?entity='.$conf->entity, 2).''; print dol_get_fiche_end(); @@ -220,11 +274,10 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Check if email exists print ''.$langs->trans("TicketsEmailMustExist").''; print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + if (empty(getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS'))) { + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; } print ''; print ''; @@ -232,6 +285,20 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; print ''; + // Create third-party with contact if email not linked to a contact + print ''.$langs->trans("TicketCreateThirdPartyWithContactIfNotExist").''; + print ''; + if (empty(getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST'))) { + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + } else { + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + } + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketCreateThirdPartyWithContactIfNotExistHelp"), 1, 'help'); + print ''; + print ''; + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Show logo for module @@ -341,7 +408,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print '

'; - print_fiche_titre($langs->trans("Emails")); + print load_fiche_titre($langs->trans("Emails")); print '
'; print ''; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 36136aeef24..7d02aea0e73 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -257,7 +257,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { } if ($execmethod == 1) { // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode. - print ''; + print ''; print ''; @@ -439,7 +439,7 @@ if (in_array($type, array('pgsql'))) { $prefix = 'pg_dump'; $ext = 'sql'; } -$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext; +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext; print ''; print '
'; print '
'; @@ -559,10 +559,10 @@ print '
'; print "
\n"; -print '
'; +print '
'; $filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); -$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles")); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:480px; overflow: auto;"'); print '
'; print '
'; @@ -594,7 +594,7 @@ print load_fiche_titre($title); print '
'; $prefix = 'documents'; $ext = 'zip'; -$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M"); +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser'); print '
'; print '
'; @@ -639,10 +639,10 @@ print '
'; print '
'; -print '
'; +print '
'; $filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); -$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles")); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow: auto;"'); print '
'; print '
'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 77dea6f23ab..c409d6a500b 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -189,7 +189,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { $param .= " -U ".$dolibarr_main_db_user; $paramcrypted = $param; $paramclear = $param; - /*if (! empty($dolibarr_main_db_pass)) + /*if (!empty($dolibarr_main_db_pass)) { $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); $paramclear.=" -p".$dolibarr_main_db_pass; diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index ea9ca86e994..902e68b381e 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -61,7 +61,11 @@ $version = '0.0'; if ($action == 'getlastversion') { $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); - $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); + if (function_exists('simplexml_load_string')) { + $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); + } else { + $sfurl = 'xml_not_available'; + } } @@ -82,7 +86,10 @@ if (function_exists('curl_init')) { $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; if ($action == 'getlastversion') { - if ($sfurl) { + if ($sfurl == 'xml_not_available') { + $langs->load("errors"); + print $langs->trans("LastStableVersion").' : '.$langs->trans("ErrorFunctionNotAvailableInPHP", 'simplexml_load_string').'
'; + } elseif ($sfurl) { $i = 0; while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { $title = $sfurl->channel[0]->item[$i]->title; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 18ce707c839..4968e75989a 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -444,9 +444,9 @@ if ($mode == 'overwrite') { if ($mode == 'searchkey') { $nbempty = 0; - /*var_dump($langcode); - var_dump($transkey); - var_dump($transvalue);*/ + //var_dump($langcode); + //var_dump($transkey); + //var_dump($transvalue); if (empty($langcode) || $langcode == '-1') { $nbempty++; } diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 53760aaa586..5f51bccb240 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -95,7 +95,7 @@ $tabfield[1] = "ref,description,virtualhost,position,date_creation"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue = array(); -$tabfieldvalue[1] = "ref,description,virtualhost,position"; +$tabfieldvalue[1] = "ref,description,virtualhost,position,entity"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert = array(); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index a68f49e36e3..47e6e87a244 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -68,7 +68,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( 'family'=>'create', 'position'=>20, - 'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)), + 'enabled'=>(!empty($conf->commande->enabled) && isModEnabled('facture')), 'picto'=>'bill' ), 'WORKFLOW_TICKET_CREATE_INTERVENTION' => array ( @@ -91,7 +91,7 @@ $workflowcodes = array( 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array( 'family'=>'classify_proposal', 'position'=>31, - 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->facture->enabled)), + 'enabled'=>(!empty($conf->propal->enabled) && isModEnabled('facture')), 'picto'=>'propal', 'warning'=>'' ), @@ -112,7 +112,7 @@ $workflowcodes = array( 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( 'family'=>'classify_order', 'position'=>42, - 'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)), + 'enabled'=>(isModEnabled('facture') && !empty($conf->commande->enabled)), 'picto'=>'order', 'warning'=>'' ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. @@ -165,7 +165,7 @@ $workflowcodes = array( 'WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE' => array( 'family' => 'classify_shipping', 'position' => 90, - 'enabled' => ! empty($conf->expedition->enabled) && ! empty($conf->facture->enabled), + 'enabled' => !empty($conf->expedition->enabled) && !empty($conf->facture->enabled), 'picto' => 'shipment' ), @@ -173,13 +173,13 @@ $workflowcodes = array( 'WORKFLOW_TICKET_LINK_CONTRACT' => array( 'family' => 'link_ticket', 'position' => 75, - 'enabled' => ! empty($conf->ticket->enabled) && ! empty($conf->contract->enabled), + 'enabled' => !empty($conf->ticket->enabled) && !empty($conf->contract->enabled), 'picto' => 'ticket' ), 'WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS' => array( 'family' => 'link_ticket', 'position' => 76, - 'enabled' => ! empty($conf->ticket->enabled) && ! empty($conf->contract->enabled), + 'enabled' => !empty($conf->ticket->enabled) && !empty($conf->contract->enabled), 'picto' => 'ticket' ), ); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index fa21c37649f..32d691400d6 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -88,9 +88,9 @@ class DolibarrApi // phpcs:enable // TODO Use type detected in $object->fields if (in_array($field, array('note', 'note_private', 'note_public', 'desc', 'description'))) { - return checkVal($value, 'restricthtml'); + return sanitizeVal($value, 'restricthtml'); } else { - return checkVal($value, 'alphanohtml'); + return sanitizeVal($value, 'alphanohtml'); } } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 81ba8e3b09d..d4d652f3e74 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -568,10 +568,9 @@ class Documents extends DolibarrApi { global $db, $conf; - /*var_dump($modulepart); - var_dump($filename); - var_dump($filecontent); - exit;*/ + //var_dump($modulepart); + //var_dump($filename); + //var_dump($filecontent);exit; if (empty($modulepart)) { throw new RestException(400, 'Modulepart not provided.'); diff --git a/htdocs/api/index.php b/htdocs/api/index.php index c66573e8022..afb0289aa32 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -100,7 +100,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $url = $_SERVER['PHP_SELF']; if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method' - $url = $_SERVER['PHP_SELF'].$_SERVER['PATH_INFO']; + $url = $_SERVER['PHP_SELF'].(empty($_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']); } // Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases) if (!empty($conf->global->MAIN_NGINX_FIX)) { diff --git a/htdocs/asset/admin/asset_extrafields.php b/htdocs/asset/admin/asset_extrafields.php index a84d3bc2016..321041d754d 100644 --- a/htdocs/asset/admin/asset_extrafields.php +++ b/htdocs/asset/admin/asset_extrafields.php @@ -88,7 +88,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/asset/admin/assetmodel_extrafields.php b/htdocs/asset/admin/assetmodel_extrafields.php index 387c43df635..7b2bbc1260d 100644 --- a/htdocs/asset/admin/assetmodel_extrafields.php +++ b/htdocs/asset/admin/assetmodel_extrafields.php @@ -88,7 +88,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index 49a0c215701..3d40cf62328 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -179,7 +179,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled)) { + if (isModEnabled('agenda')) { if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { print '' . $langs->trans("AddAction") . ''; } else { @@ -189,7 +189,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $param = '&id=' . $object->id . '&socid=' . $socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage=' . urlencode($contextpage); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index c516866b7d0..d94ba613d91 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -408,7 +408,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/asset/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/asset/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 19c15839231..410af398bc7 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -144,6 +144,7 @@ class Asset extends CommonObject public $fk_disposal_type; public $disposal_depreciated; public $disposal_subject_to_vat; + public $supplier_invoice_id; public $note_public; public $note_private; public $date_creation; diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index eae7b5d0fde..077f33936e8 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -105,7 +105,6 @@ class AssetModel extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'showoncombobox'=>'2', 'validate'=>'1',), 'asset_type' => array('type'=>'smallint', 'label'=>'AssetType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'AssetTypeIntangible', '1'=>'AssetTypeTangible', '2'=>'AssetTypeInProgress', '3'=>'AssetTypeFinancial'), 'validate'=>'1',), - 'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>1, 'position'=>50), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>301, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -129,6 +128,7 @@ class AssetModel extends CommonObject public $import_key; public $model_pdf; public $status; + public $asset_depreciation_options; // /** // * @var string Field with ID of parent key if this object has a parent diff --git a/htdocs/asset/model/accountancy_codes.php b/htdocs/asset/model/accountancy_codes.php index fd5999b20b0..7582b61177e 100644 --- a/htdocs/asset/model/accountancy_codes.php +++ b/htdocs/asset/model/accountancy_codes.php @@ -52,8 +52,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index cd0365a1418..f1db3030dc2 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -80,8 +80,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/model/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); @@ -181,7 +181,7 @@ if ($object->id > 0) { print '
'; - // if (!empty($conf->agenda->enabled)) { + // if (isModEnabled('agenda')) { // if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { // print '' . $langs->trans("AddAction") . ''; // } else { @@ -191,7 +191,7 @@ if ($object->id > 0) { print '
'; - // if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + // if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { // $param = '&id=' . $object->id . '&socid=' . $socid; // if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { // $param .= '&contextpage=' . urlencode($contextpage); diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php index 3e0858da55e..3d3ec2f67d2 100644 --- a/htdocs/asset/model/card.php +++ b/htdocs/asset/model/card.php @@ -68,9 +68,9 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php $permissiondellink = $permissiontoadd; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -300,7 +300,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&token=' . newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . (!empty($socid) ? '&socid=' . $socid : '') . '&action=clone&token=' . newToken(), '', $permissiontoadd); // Delete (need delete permission, or if draft, just need create/modify permission) print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); @@ -315,7 +315,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // $MAXEVENT = 10; // - // $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id); + // $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id); // // // List of actions on element // include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; diff --git a/htdocs/asset/model/depreciation_options.php b/htdocs/asset/model/depreciation_options.php index f5bc751663b..c34bd38dc46 100644 --- a/htdocs/asset/model/depreciation_options.php +++ b/htdocs/asset/model/depreciation_options.php @@ -52,8 +52,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index a6423bb3a73..a55d5f49f9a 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -121,9 +121,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); -$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->delete))); +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); +$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))); // Security check if (empty($conf->asset->enabled)) { @@ -131,15 +131,18 @@ if (empty($conf->asset->enabled)) { } // Security check (enable the most restrictive one) -if ($user->socid > 0) accessforbidden(); -$socid = 0; if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + accessforbidden(); +} +$socid = 0; +if ($user->socid > 0) { + $socid = $user->socid; +} $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); if (empty($conf->asset->enabled)) accessforbidden(); if (!$permissiontoread) accessforbidden(); - - /* * Actions */ @@ -300,19 +303,20 @@ $sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrin $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* This old and fast method to get and count full list returns all record so use a high amount of memory. - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); */ - /* The slow method does not consume memory on mysql (not tested on pgsql) */ - /*$resql = $db->query($sql, 0, 'auto', 1); - while ($db->fetch_object($resql)) { - $nbtotalofrecords++; - }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; diff --git a/htdocs/asset/model/note.php b/htdocs/asset/model/note.php index 4af8407976f..8c88feba449 100644 --- a/htdocs/asset/model/note.php +++ b/htdocs/asset/model/note.php @@ -50,8 +50,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php // Security check (enable the most restrictive one) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 1a5f99b27ee..b4e365fe018 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -188,7 +188,7 @@ print ''; print '
'; // For thirdparty -if ($conf->societe->enabled) { +if (isModEnabled('societe')) { $nbno = $nbtotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"), '', 'company'); diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index eb851af169a..e6f9ea0de15 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -92,11 +92,11 @@ function formatObject($objtoshow, $prefix) $s .= ''.($prefix ? $prefix.' > ' : '').$key.''; $s .= ''; if (in_array($key, array('date', 'datef', 'dateh', 'datec', 'datem', 'datep'))) { - /*var_dump(is_object($val)); - var_dump(is_array($val)); - var_dump(is_array($val)); - var_dump(@get_class($val)); - var_dump($val);*/ + //var_dump(is_object($val)); + //var_dump(is_array($val)); + //var_dump(is_array($val)); + //var_dump(@get_class($val)); + //var_dump($val); $s .= dol_print_date($val, 'dayhour'); } else { $s .= $val; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 578e1afa497..ea5069cb840 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2017-2020 Laurent Destailleur +/* Copyright (C) 2017 ATM Consulting + * Copyright (C) 2017-2020 Laurent Destailleur + * Copyright (C) 2022 charlene 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 @@ -139,76 +140,53 @@ class BlockedLog $this->trackedevents = array(); - if ($conf->facture->enabled) { + if (isModEnabled('facture')) { $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE'; - } - if ($conf->facture->enabled) { $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE'; - } - if ($conf->facture->enabled) { $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL'; - } - if ($conf->facture->enabled) { $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload'; - } - if ($conf->facture->enabled) { $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview'; - } - if ($conf->facture->enabled) { $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE'; - } - if ($conf->facture->enabled) { $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE'; } /* Supplier - if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; - if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete'; - if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done - if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done - if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done + if (!empty($conf->fournisseur->enabled)) { + $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; + $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete'; + $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done + $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done + $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done - if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate'; - if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; + $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate'; + $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; + } */ - if ($conf->don->enabled) { + if (!empty($conf->don->enabled)) { $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE'; - } - if ($conf->don->enabled) { $this->trackedevents['DON_DELETE'] = 'logDON_DELETE'; - } - //if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; - - if ($conf->don->enabled) { + //$this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE'; - } - if ($conf->don->enabled) { $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE'; } /* - if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; - if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate'; - if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; + if (!empty($conf->salary->enabled)) { + $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; + $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate'; + $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; + } */ - if ($conf->adherent->enabled) { + if (!empty($conf->adherent->enabled)) { $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE'; - } - if ($conf->adherent->enabled) { $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY'; - } - if ($conf->adherent->enabled) { $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE'; } - if ($conf->banque->enabled) { + if (!empty($conf->banque->enabled)) { $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE'; - } - if ($conf->banque->enabled) { $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY'; - } - if ($conf->banque->enabled) { $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE'; } // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all external POS modules diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 2b9c6f57bbd..d2c64eea0b6 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$socid = GETPOST('socid', 'int'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -79,7 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bom->multidir_output[$object->entity]."/".$object->id; + $upload_dir = (!empty($conf->bom->multidir_output[$object->entity]) ? $conf->bom->multidir_output[$object->entity] : $conf->bom->dir_output)."/".$object->id; } // Security check - Protection if external user @@ -149,7 +150,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (! empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; @@ -219,7 +220,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled)) { + if (isModEnabled('agenda')) { if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { print ''.$langs->trans("AddAction").''; } else { @@ -229,7 +230,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 96fb68b6e9b..ee619a589e3 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; + // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); @@ -474,7 +476,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (! empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; @@ -581,47 +583,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print "\n"; - ?> - - - id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Create MO - if ($conf->mrp->enabled) { + if (isModEnabled('mrp')) { if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) { print ''.$langs->trans("CreateMO").''."\n"; } @@ -742,7 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 64f3cdbfac1..a0390ef5105 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -104,6 +104,7 @@ $form = new Form($db); $title = $langs->trans("BillOfMaterials").' - '.$langs->trans("Files"); $help_url = 'EN:Module_BOM'; +$morehtmlref = ""; llxHeader('', $title, $help_url); diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index 30cd6792c55..baf4b096324 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -34,6 +34,7 @@ $langs->loadLangs(array("mrp", "other", "stocks")); // Get parameters $id = GETPOST('id', 'int'); +$lineid = GETPOST('lineid', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); @@ -184,10 +185,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - $viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-list-alt imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); + $viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); $viewlink .= dolGetButtonTitle($langs->trans('TreeStructure'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':''))); - print load_fiche_titre($langs->trans("BillOfMaterials"), $viewlink, 'cubes'); + print load_fiche_titre($langs->trans("BOMNetNeeds"), $viewlink, ''); /* * Lines diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 8ace40cc900..9984a1498b8 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -54,7 +54,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bom->multidir_output[$object->entity]."/".$object->id; + $upload_dir = (!empty($conf->bom->multidir_output[$object->entity]) ? $conf->bom->multidir_output[$object->entity] : $conf->bom->dir_output)."/".$object->id; } $permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 86e07ed424d..598c4c73945 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -820,13 +820,6 @@ class BOM extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('bomdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -916,27 +909,27 @@ class BOM extends CommonObject if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) { + if (!empty($obj->fk_user_author)) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) { + if (!empty($obj->fk_user_valid)) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) { + if (!empty($obj->fk_user_cloture)) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); + $this->date_modification = !empty($obj->datem) ? $this->db->jdate($obj->datem) : ""; + $this->date_validation = !empty($obj->datev) ? $this->db->jdate($obj->datev) : ""; } $this->db->free($result); @@ -958,8 +951,8 @@ class BOM extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_bom = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1134,6 +1127,9 @@ class BOM extends CommonObject if (! empty($line->childBom)) { foreach ($line->childBom as $childBom) $childBom->getNetNeeds($TNetNeeds, $line->qty*$qty); } else { + if (empty($TNetNeeds[$line->fk_product])) { + $TNetNeeds[$line->fk_product] = 0; + } $TNetNeeds[$line->fk_product] += $line->qty*$qty; } } @@ -1298,6 +1294,7 @@ class BOMLine extends CommonObjectLine */ public $childBom = array(); + /** * Constructor * @@ -1511,13 +1508,6 @@ class BOMLine extends CommonObjectLine } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('bomlinedao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 954959d5d7a..94debfbee7b 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -136,3 +136,55 @@ function bomPrepareHead($object) return $head; } + +/** + * Manage collapse bom display + * + * @return void + */ +function mrpCollapseBomManagement() +{ + ?> + + + + '; - print "".$langs->trans("NewAttribute").""; + print ''.$langs->trans("NewAttribute").''; print ""; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 434b994ccd2..14cdfe84783 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -37,6 +37,7 @@ 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'; +require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php'; /** @@ -113,7 +114,7 @@ class Categorie extends CommonObject * * @todo Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_CAT_FK = array( + public $MAP_CAT_FK = array( 'customer' => 'soc', 'supplier' => 'soc', 'contact' => 'socpeople', @@ -125,7 +126,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_CAT_TABLE = array( + public $MAP_CAT_TABLE = array( 'customer' => 'societe', 'supplier' => 'fournisseur', 'bank_account'=> 'account', @@ -136,7 +137,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_OBJ_CLASS = array( + public $MAP_OBJ_CLASS = array( 'product' => 'Product', 'customer' => 'Societe', 'supplier' => 'Fournisseur', @@ -178,7 +179,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_OBJ_TABLE = array( + public static $MAP_OBJ_TABLE = array( 'customer' => 'societe', 'supplier' => 'societe', 'member' => 'adherent', @@ -258,6 +259,12 @@ class Categorie extends CommonObject */ public $motherof = array(); + /** + * @var array Childs + */ + public $childs = array(); + + /** * Constructor * @@ -819,7 +826,7 @@ class Categorie extends CommonObject /** * Return list of fetched instance of elements having this category * - * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member', ...) + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member', 'knowledge_management' ...) * @param int $onlyids Return only ids of objects (consume less memory) * @param int $limit Limit * @param int $offset Offset @@ -913,7 +920,7 @@ class Categorie extends CommonObject $categories = array(); - $type = checkVal($type, 'aZ09'); + $type = sanitizeVal($type, 'aZ09'); $sub_type = $type; $subcol_name = "fk_".$type; @@ -982,7 +989,7 @@ class Categorie extends CommonObject $categories[$i]['array_options'] = $category_static->array_options; // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS) && isset($category_static->multilangs)) { $categories[$i]['multilangs'] = $category_static->multilangs; } } diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index f4456ed79bf..4a9e771416c 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -102,7 +102,8 @@ if (empty($nosearch)) { print ''.$langs->trans("Search").''; print ''; print ''; - print $langs->trans("Name").':'; + print $langs->trans("Name").':'; + print ''; print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index aa513e07794..351ab9212bc 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -461,6 +461,13 @@ if (empty($reshook) && $action == 'add') { } } + // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. + /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; + $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; + $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; + */ + $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; + if ($error) { $db->rollback(); } else { @@ -674,7 +681,7 @@ if (empty($reshook) && $action == 'update') { $object->errors[] = $object->error; } else { if ($db->num_rows($resql) > 0) { - // already in use + // Resource already in use $error++; $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { @@ -853,7 +860,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { $object->errors[] = $object->error; } else { if ($db->num_rows($resql) > 0) { - // already in use + // Resource already in use $error++; $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { @@ -952,16 +959,17 @@ if ($action == 'create') { console.log("setdatefields"); setdatefields(); }); + $("#selectcomplete").change(function() { - if ($("#selectcomplete").val() == 100) - { + console.log("we change the complete status - set the doneby"); + if ($("#selectcomplete").val() == 100) { if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).'\'); } - if ($("#selectcomplete").val() == 0) - { + if ($("#selectcomplete").val() == 0) { $("#doneby").val(-1); } }); + $("#actioncode").change(function() { if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); else $("#dateend").removeClass("fieldrequired"); @@ -1019,59 +1027,15 @@ if ($action == 'create') { print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").''; // Full day - print ''; + print ''.$langs->trans("Date").''; - $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); - if (GETPOST('datep', 'int', 1)) { - $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser'); - } - $datef = ($datef ? $datef : $object->datef); - if (GETPOST('datef', 'int', 1)) { - $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser'); - } - if (empty($datef) && !empty($datep)) { - if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { - $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); - } - } - - // Date start - print ''; - print ''.$langs->trans("DateActionStart").''; - print ' - '; - print ''.$langs->trans("DateActionEnd").''; - print ''; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo" - } else { - print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); - } - print '     -     '; - //print ' - '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } - print ''; - - // Date end - /*print ''; - print ''.$langs->trans("DateActionEnd").''; - print ''; - print ''; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); - } - print '';*/ - - // Dev in progress + // Recurring event $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { // Repeat - print ''; + //print ''; + print '        
'; + print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; $selectedrecurrulefreq = 'no'; $selectedrecurrulebymonthday = ''; @@ -1120,34 +1084,51 @@ if ($action == 'create') { }); }); '; - print ''; + print '
'; + //print ''; } - // Status - print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - print ''; - $percent = $complete !=='' ? $complete : -1; - if (GETPOSTISSET('status')) { - $percent = GETPOST('status'); - } elseif (GETPOSTISSET('percentage')) { - $percent = GETPOST('percentage', 'int'); - } else { - if ($complete == '0' || GETPOST("afaire") == 1) { - $percent = '0'; - } elseif ($complete == 100 || GETPOST("afaire") == 2) { - $percent = 100; - } - } - $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); + if (GETPOST('datep', 'int', 1)) { + $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser'); + } + $datef = ($datef ? $datef : $object->datef); + if (GETPOST('datef', 'int', 1)) { + $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser'); + } + if (empty($datef) && !empty($datep)) { + if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { + $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); + } } + // Date start + print ''; + /* + print ''.$langs->trans("DateActionStart").''; + print ' - '; + print ''.$langs->trans("DateActionEnd").''; + */ + print ''; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo" + } else { + print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); + } + print '     -     '; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); + } else { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); + } + print ''; + + print ' '; + // Assigned to - print ''.$langs->trans("ActionAffectedTo").''; + print ''.$langs->trans("ActionAffectedTo").''; $listofuserid = array(); $listofcontactid = array(); $listofotherid = array(); @@ -1181,7 +1162,30 @@ if ($action == 'create') { print ''; } - if ($conf->categorie->enabled) { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { + print ''.$langs->trans("Location").''; + } + + // Status + print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + print ''; + $percent = $complete !=='' ? $complete : -1; + if (GETPOSTISSET('status')) { + $percent = GETPOST('status'); + } elseif (GETPOSTISSET('percentage')) { + $percent = GETPOST('percentage', 'int'); + } else { + if ($complete == '0' || GETPOST("afaire") == 1) { + $percent = '0'; + } elseif ($complete == 100 || GETPOST("afaire") == 2) { + $percent = 100; + } + } + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); + print ''; + + if (!empty($conf->categorie->enabled)) { // Categories print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); @@ -1197,7 +1201,7 @@ if ($action == 'create') { print ''; - if ($conf->societe->enabled) { + if (!empty($conf->societe->enabled)) { // Related company print ''; + print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Title").''; // Full day event - print ''; + print ''; - - // Dev in progress + // Recurring event $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { // Repeat - print ''; + print ''; + //print ''; } - - // Status - print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''; + // Date start - end + print ''; + + print ''; // Assigned to $listofuserid = array(); // User assigned @@ -1678,8 +1680,20 @@ if ($id > 0) { print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1, 'doneby', 1); print ''; } + + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { + print ''; + } + + // Status + print ''; + // Tags-Categories - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { print ''; +} + + +print '
'.$langs->trans("ActionOnCompany").''; if (GETPOST('socid', 'int') > 0) { @@ -1230,14 +1234,14 @@ if ($action == 'create') { } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $projectid = GETPOST('projectid', 'int'); print '
'.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects((empty($societe->id) ? '' : $societe->id), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' '; print ''; @@ -1523,6 +1527,7 @@ if ($id > 0) { if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print '
'.$langs->trans("Type").''; if ($object->type_code != 'AC_OTH_AUTO') { + print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); print $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ? GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto", 0, 0, 0, 1); } else { print ''; @@ -1533,40 +1538,19 @@ if ($id > 0) { } // Title - print '
'.$langs->trans("Title").'
'.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>
'.$langs->trans("Date").'fulldayevent ? ' checked' : '').'>'; + print ''; - // Date start - end - print '
'; - print ''.$langs->trans("DateActionStart").''; - print ' - '; - print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; - print ''; - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } - print ' - '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } - print '
'; + //print '
'; + print '        
'; + print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; $selectedrecurrulefreq = 'no'; $selectedrecurrulebymonthday = ''; @@ -1615,19 +1599,37 @@ if ($id > 0) { }); }); '; - print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage; - $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print '
'.$langs->trans("Location").'
'; + /*print ''.$langs->trans("DateActionStart").''; + print ' - '; + print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; + */ + print ''; + $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); + if (GETPOST("afaire") == 1) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } else { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); } + print '     -     '; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } else { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } + print '
 
'.$langs->trans("Location").'
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage; + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); + print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1700,7 +1714,7 @@ if ($id > 0) { print ''; - if ($conf->societe->enabled) { + if (!empty($conf->societe->enabled)) { // Related company print ''; print ''; print ''; - if ($object->elementtype == 'task' && !empty($conf->projet->enabled)) { + if ($object->elementtype == 'task' && !empty($conf->project->enabled)) { print ''; @@ -1898,7 +1912,7 @@ if ($id > 0) { $linkback = ''; // Link to other agenda views $linkback .= ''; - $linkback .= img_picto($langs->trans("BackToList"), 'object_list', 'class="pictoactionview pictofixedwidth"'); + $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); $linkback .= ''.$langs->trans("BackToList").''; $linkback .= ''; $linkback .= ''; @@ -1932,7 +1946,7 @@ if ($id > 0) { // Thirdparty //$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); //$morehtmlref.='
'.$langs->trans('Project') . ' '; $morehtmlref .= $langs->trans('Project').' '; @@ -2085,7 +2099,7 @@ if ($id > 0) { } // Categories - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { print '"; @@ -2100,7 +2114,7 @@ if ($id > 0) { print '
'; print '
'.$langs->trans("ActionOnCompany").''; @@ -1723,7 +1737,7 @@ if ($id > 0) { } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); print '
'.$langs->trans("Project").''; @@ -1748,7 +1762,7 @@ if ($id > 0) { print '
'.$langs->trans("LinkedObject").''; $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility @@ -1786,7 +1800,7 @@ if ($id > 0) { print '
'.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('note', $object->note_private, '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); $doleditor->Create(); print '
'.$langs->trans("Categories").''; print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1); print "
'; - if ($conf->societe->enabled) { + if (!empty($conf->societe->enabled)) { // Related company print ''; -print "\n"; +print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- print ''; if (!empty($arrayfields['a.id']['checked'])) { print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['owner']['checked'])) { print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['c.libelle']['checked'])) { print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.label']['checked'])) { print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.note']['checked'])) { print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($arrayfields['a.datep']['checked'])) { print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.datep2']['checked'])) { print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.fk_contact']['checked'])) { print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.fk_element']['checked'])) { print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } - // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -842,18 +860,21 @@ print $hookmanager->resPrint; if (!empty($arrayfields['a.datec']['checked'])) { print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.tms']['checked'])) { print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.percent']['checked'])) { print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +$totalarray['nbfield']++; print "\n"; -$contactstatic = new Contact($db); $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; @@ -862,8 +883,20 @@ $caction = new CActionComm($db); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $contactListCache = array(); -while ($i < min($num, $limit)) { +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +//$savnbfield = $totalarray['nbfield']; +//$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + + // Store properties in $object + $object->setVarsFromFetchObj($obj); // Discard auto action if option is on if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { @@ -1080,12 +1113,20 @@ while ($i < min($num, $limit)) { } print ''; - print "\n"; + print ''."\n"; + $i++; } -print "
'.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9d122cfce7e..156d5573ae8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -389,6 +389,9 @@ class ActionComm extends CommonObject const EVENT_FINISHED = 100; + public $fields = array(); + + /** * Constructor * @@ -1142,8 +1145,16 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", fk_action = ".(int) $this->type_id; + if (empty($this->type_code)) { + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($this->type_id); + if ($result >= 0 && !empty($cactioncomm->code)) { + $this->type_code = $cactioncomm->code; + } + } } + $sql .= ", code = " . (isset($this->type_code)? "'".$this->db->escape($this->type_code) . "'":"null"); $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); @@ -1220,11 +1231,14 @@ class ActionComm extends CommonObject if (!empty($this->socpeopleassigned)) { $already_inserted = array(); - foreach (array_keys($this->socpeopleassigned) as $id) { + foreach (array_keys($this->socpeopleassigned) as $key => $val) { + if (!is_array($val)) { // For backward compatibility when val=id + $val = array('id'=>$val); + } 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(".((int) $this->id).", 'socpeople', ".((int) $id).", 0, 0, 0)"; + $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $val['id']).", 0, 0, 0)"; $resql = $this->db->query($sql); if (!$resql) { @@ -1598,7 +1612,7 @@ class ActionComm extends CommonObject //$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").''; $tooltip .= '
'.$langs->trans('MailTopic').': '.$this->email_subject; $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); - $tooltip .= '
'.$langs->trans('MailTo').':, '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); if (!empty($this->email_tocc)) { $tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); } @@ -1621,14 +1635,8 @@ class ActionComm extends CommonObject $label = $langs->trans("ShowAction"); $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, 0, '', 1).'"'; + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"'; $linkclose .= ' class="'.$classname.' classfortooltip"'; - /* - $hookmanager->initHooks(array('actiondao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); - */ } else { $linkclose .= ' class="'.$classname.'"'; } @@ -2505,14 +2513,16 @@ class ActionComm extends CommonObject * * @param int $id The id of the event * @param int $percent The new percent value for the event + * @param int $usermodid The user who modified the percent * @return int 1 when update of the event was suscessfull, otherwise -1 */ - public function updatePercent($id, $percent) + public function updatePercent($id, $percent, $usermodid = 0) { $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = ".(int) $percent; + if ($usermodid > 0) $sql .= ", fk_user_mod = ".$usermodid; $sql .= " WHERE id = ".((int) $id); if ($this->db->query($sql)) { diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 8dd6b008045..d2b089491a7 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -198,7 +198,7 @@ class CActionComm //var_dump($obj->type.' '.$obj->module.' '); var_dump($user->rights->facture->lire); $qualified = 0; // Special cases - if ($obj->module == 'invoice' && !empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { + if ($obj->module == 'invoice' && isModEnabled('facture') && !empty($user->rights->facture->lire)) { $qualified = 1; } if ($obj->module == 'order' && !empty($conf->commande->enabled) && empty($user->rights->commande->lire)) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 3de00e9cb6f..90ed4ea1944 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -139,7 +139,7 @@ if ($object->id > 0) { print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); - $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); + $linkback = img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="hideonsmartphone pictoactionview"'); $linkback .= ''.$langs->trans("BackToList").''; // Link to other agenda views @@ -159,7 +159,7 @@ if ($object->id > 0) { // Thirdparty //$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); //$morehtmlref.='
'.$langs->trans('Project') . ' '; $morehtmlref .= $langs->trans('Project').': '; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 4f8b8509f4e..9fcb8375193 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -49,6 +49,8 @@ if (empty($conf->global->AGENDA_EXT_NB)) { } $MAXAGENDA = $conf->global->AGENDA_EXT_NB; +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); + $check_holiday = GETPOST('check_holiday', 'int'); $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); @@ -110,7 +112,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); $pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' -$type = GETPOSTISSET("search_type", 'aZ09') ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); +$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); $maxprint = GETPOSTISSET("maxprint") ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW; $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -128,14 +130,11 @@ if (GETPOST('search_actioncode', 'array:aZ09')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($status == '' && !GETPOSTISSET('search_status')) { - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -498,7 +497,7 @@ print ''; $viewmode = ''; $viewmode .= ''; //$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="imgforviewmode pictoactionview block"'); +$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"'); //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewList").''; @@ -849,7 +848,6 @@ if ($resql) { $event->fk_project = $obj->fk_project; $event->socid = $obj->fk_soc; - $event->thirdparty_id = $obj->fk_soc; $event->contact_id = $obj->fk_contact; // Defined date_start_in_calendar and date_end_in_calendar property @@ -1191,7 +1189,8 @@ if (count($listofextcals)) { foreach ($icalevents as $icalevent) { //var_dump($icalevent); - //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; + //print $icalevent['SUMMARY'].'->'; + //var_dump($icalevent);exit; if (!empty($icalevent['RRULE'])) { continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 225bc8b29fc..0ea24279df4 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -66,7 +66,7 @@ $object->info($object->id); $head = actions_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); -$linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); +$linkback = img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="hideonsmartphone pictoactionview"'); $linkback .= ''.$langs->trans("BackToList").''; // Link to other agenda views @@ -86,7 +86,7 @@ $morehtmlref = '
'; // Thirdparty //$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); //$morehtmlref.='
'.$langs->trans('Project') . ' '; $morehtmlref .= $langs->trans('Project').': '; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 86b8a3b5ce5..06e6684d99b 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -45,6 +45,11 @@ $langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", " $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search +$optioncss = GETPOST('optioncss', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$confirm = GETPOST('confirm', 'alpha'); + +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); $mode = GETPOST('mode', 'aZ09'); if (empty($mode) && preg_match('/show_/', $action)) { @@ -54,12 +59,9 @@ $resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", $pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); $search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); -$optioncss = GETPOST('optioncss', 'alpha'); $year = GETPOST("year", 'int'); $month = GETPOST("month", 'int'); $day = GETPOST("day", 'int'); -$toselect = GETPOST('toselect', 'array'); -$confirm = GETPOST('confirm', 'alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { @@ -68,11 +70,9 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } + $search_id = GETPOST('search_id', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_note = GETPOST('search_note', 'alpha'); @@ -83,7 +83,7 @@ $datestart_dtend = dol_mktime(23, 59, 59, GETPOST('datestart_dtendmonth', 'int') $dateend_dtstart = dol_mktime(0, 0, 0, GETPOST('dateend_dtstartmonth', 'int'), GETPOST('dateend_dtstartday', 'int'), GETPOST('dateend_dtstartyear', 'int'), 'tzuserrel'); $dateend_dtend = dol_mktime(23, 59, 59, GETPOST('dateend_dtendmonth', 'int'), GETPOST('dateend_dtendday', 'int'), GETPOST('dateend_dtendyear', 'int'), 'tzuserrel'); if ($search_status == '' && !GETPOSTISSET('search_status')) { - $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $search_status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -183,7 +183,8 @@ if ($user->socid && $socid) { */ if (GETPOST('cancel', 'alpha')) { - $mode = 'list'; $massaction = ''; + $mode = 'list'; + $massaction = ''; } if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { @@ -216,7 +217,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $datestart_dtend = ''; $dateend_dtstart = ''; $dateend_dtend = ''; + $actioncode = ''; $search_status = ''; + $pid = ''; + $socid = ''; + $resourceid = ''; + $filter = ''; + $filtert = ''; + $usergroup = ''; $toselect = array(); $search_array_options = array(); } @@ -261,13 +269,17 @@ if (empty($reshook)) { } /* - * View + * View */ $form = new Form($db); $userstatic = new User($db); $formactions = new FormActions($db); +$actionstatic = new ActionComm($db); +$societestatic = new Societe($db); +$contactstatic = new Contact($db); + $nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; @@ -275,7 +287,8 @@ $nav .= ' trans("Agenda"); +llxHeader('', $title, $help_url); // Define list of all external calendars $listofextcals = array(); @@ -299,7 +312,7 @@ if ($actioncode != '') { if ($resourceid > 0) { $param .= "&search_resourceid=".urlencode($resourceid); } -if ($search_status != '' && $search_status > -1) { +if ($search_status != '') { $param .= "&search_status=".urlencode($search_status); } if ($filter) { @@ -563,11 +576,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } @@ -588,12 +601,6 @@ if (!$resql) { $num = $db->num_rows($resql); - -$actionstatic = new ActionComm($db); -$societestatic = new Societe($db); - -$num = $db->num_rows($resql); - $arrayofselected = is_array($toselect) ? $toselect : array(); // Local calendar @@ -635,7 +642,6 @@ $s = $newtitle; // Calendars from hooks $parameters = array(); -$object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { $s .= $hookmanager->resPrint; @@ -648,7 +654,7 @@ $viewday = is_object($object) ? dol_print_date($object->datep, '%d') : ''; $viewmode = ''; $viewmode .= ''; //$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="imgforviewmode pictoactionview block"'); +$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"'); //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewList").''; @@ -680,7 +686,6 @@ $viewmode .= ''; // Add more views from hooks $parameters = array(); -$object = null; $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); if (empty($reshook)) { $viewmode .= $hookmanager->resPrint; @@ -797,44 +802,57 @@ print '
'; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
"; -print ''; -print ''; +// If no record found +if ($num == 0) { + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print ''."\n"; + +print ''."\n"; $db->free($resql); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 9869bd2d305..85eb355f2b6 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -45,6 +45,8 @@ if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { $action = GETPOST('action', 'aZ09'); +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); + $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); @@ -110,10 +112,7 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); @@ -145,7 +144,7 @@ $begin_d = 1; $end_d = 53; if ($status == '' && !GETPOSTISSET('search_status')) { - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -421,7 +420,7 @@ $massactionbutton = ''; $viewmode = ''; $viewmode .= ''; //$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="imgforviewmode pictoactionview block"'); +$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"'); //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewList").''; @@ -961,7 +960,9 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); $nextindextouse = count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... - //if ($username->id && $day==1) var_dump($eventarray); + //if ($username->id && $day==1) { + //var_dump($eventarray); + //} // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 68c9088815d..18f62872630 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -45,6 +45,8 @@ if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { $action = GETPOST('action', 'aZ09'); +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); + $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); @@ -99,7 +101,7 @@ $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -110,10 +112,7 @@ if (GETPOST('search_actioncode', 'array:aZ09')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); @@ -154,7 +153,7 @@ if ($end_d < $begin_d) { } if ($status == '' && !GETPOSTISSET('search_status')) { - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { @@ -433,7 +432,7 @@ $massactionbutton = ''; $viewmode = ''; $viewmode .= ''; //$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="imgforviewmode pictoactionview block"'); +$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"'); //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewList").''; @@ -515,7 +514,6 @@ $s = $newtitle; print $s; print '
'; - print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print '
'; @@ -1130,7 +1128,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 $nextindextouse = count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... - //if ($username->id && $day==1) var_dump($eventarray); + //if ($username->id && $day==1) { + //var_dump($eventarray); + //} // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index bfa62eba7fc..7a4cfe7a6ea 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -82,7 +82,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 19b7674449f..91517d456c5 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -85,7 +85,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 411efc5ae93..01d7102a47c 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -40,10 +40,8 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->facture->enabled)) { +if (isModEnabled('facture')) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -} -if (!empty($conf->facture->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; } if (!empty($conf->propal->enabled)) { @@ -77,10 +75,10 @@ if (!empty($conf->commande->enabled)) { if (!empty($conf->expedition->enabled)) { $langs->load("sendings"); } -if (!empty($conf->facture->enabled)) { +if (isModEnabled('facture')) { $langs->load("bills"); } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); } if (!empty($conf->ficheinter->enabled)) { @@ -741,7 +739,7 @@ if ($object->id > 0) { } } - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->rights->facture->lire) { // Box factures $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; @@ -827,7 +825,7 @@ if ($object->id > 0) { $sql .= ", p.total_tva"; $sql .= ", p.total_ttc"; $sql .= ", p.ref, p.ref_client, p.remise"; - $sql .= ", p.datep as dp, p.fin_validite as date_limit"; + $sql .= ", p.datep as dp, p.fin_validite as date_limit, p.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql .= " AND s.rowid = ".((int) $object->id); @@ -887,7 +885,7 @@ if ($object->id > 0) { } } $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0, $param); + print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); @@ -1226,7 +1224,7 @@ if ($object->id > 0) { * Latest interventions */ if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { - $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; + $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND s.rowid = ".((int) $object->id); @@ -1261,7 +1259,7 @@ if ($object->id > 0) { print ''; print $fichinter_static->getNomUrl(1); // Preview - $filedir = $conf->fichinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); + $filedir = $conf->ficheinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); $file_list = null; if (!empty($filedir)) { $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); @@ -1283,7 +1281,7 @@ if ($object->id > 0) { } } $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0, $param); + print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->fichinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); @@ -1311,7 +1309,7 @@ if ($object->id > 0) { /* * Latest invoices templates */ - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as id, f.titre as ref'; $sql .= ', f.total_ht'; $sql .= ', f.total_tva'; @@ -1406,7 +1404,7 @@ if ($object->id > 0) { /* * Latest invoices */ - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as facid, f.ref, f.type'; $sql .= ', f.total_ht'; $sql .= ', f.total_tva'; @@ -1569,7 +1567,7 @@ if ($object->id > 0) { print ''; } - if (!empty($conf->facture->enabled) && $object->status == 1) { + if (isModEnabled('facture') && $object->status == 1) { if (empty($user->rights->facture->creer)) { print ''; } else { @@ -1597,7 +1595,7 @@ if ($object->id > 0) { } // Add action - if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { + if (isModEnabled('agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { if ($user->rights->agenda->myactions->create) { print ''; } else { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index dafc1e7ee16..5903b7e4bdb 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -634,7 +634,11 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { print $s; print ''; - print ''.dol_print_date($db->jdate($objp->tms), 'day').''; + + $datem = $db->jdate($objp->tms); + print ''; + print dol_print_date($datem, 'day', 'tzuserrel'); + print ''; print ''; $i++; @@ -725,7 +729,11 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S print $s; print ''; - print ''.dol_print_date($db->jdate($objp->dm), 'day').''; + + $datem = $db->jdate($objp->dm); + print ''; + print dol_print_date($datem, 'day', 'tzuserrel'); + print ''; print ''; $i++; @@ -922,7 +930,10 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { print ''; print ''.$companystatic->getNomUrl(1, 'customer', 44).''; - print ''.dol_print_date($db->jdate($obj->dp), 'day').''; + $datem = $db->jdate($obj->dp); + print ''; + print dol_print_date($datem, 'day', 'tzserver'); + print ''; print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''; @@ -1039,7 +1050,11 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { print ''; print ''.$companystatic->getNomUrl(1, 'customer', 44).''; - print ''.dol_print_date($db->jdate($obj->dv), 'day').''; + $datem = $db->jdate($obj->dv); + print ''; + print dol_print_date($datem, 'day', 'tzserver'); + print ''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index f82df06313b..b3d3dd25e90 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -961,7 +961,7 @@ if ($action == 'create') { if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { print "\n\n
\n"; - if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) { + if (($object->statut == 1) && ($user->rights->mailing->valider || $object->user_validation == $user->id)) { print ''.$langs->trans("SetToDraft").''; } @@ -1066,7 +1066,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print dol_set_focus('#sendto'); + dol_set_focus('#sendto'); } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 9069b63179f..aaf100d191a 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -135,7 +135,7 @@ if (GETPOST('exportcsv', 'int')) { $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,"; $sql .= " mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.fk_mailing=".((int) $object->id); + $sql .= " WHERE mc.fk_mailing = ".((int) $object->id); $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); @@ -365,17 +365,19 @@ if ($object->fetch($id) >= 0) { $obj = new $classname($db); + // Check if qualified + $qualified = (is_null($obj->enabled) ? 1 : dol_eval($obj->enabled, 1)); + // Check dependencies - $qualified = (isset($obj->enabled) ? $obj->enabled : 1); foreach ($obj->require_module as $key) { - if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin)) { + if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) { $qualified = 0; //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif"; break; } } - // Si le module mailing est qualifie + // If module is qualified if ($qualified) { $var = !$var; @@ -402,7 +404,7 @@ if ($object->fetch($id) >= 0) { } print '
'; - if ($nbofrecipient >= 0) { + if ($nbofrecipient === '' || $nbofrecipient >= 0) { print $nbofrecipient; } else { print $langs->trans("Error").' '.img_error($obj->error); @@ -638,10 +640,10 @@ if ($object->fetch($id) >= 0) { $obj = $db->fetch_object($resql); print ''; - print ''.img_picto('$obj->email', 'email', 'class="paddingright"').$obj->email.''; - print ''.$obj->lastname.''; - print ''.$obj->firstname.''; - print ''.$obj->other.''; + print ''.img_picto('$obj->email', 'email', 'class="paddingright"').dol_escape_htmltag($obj->email).''; + print ''.dol_escape_htmltag($obj->lastname).''; + print ''.dol_escape_htmltag($obj->firstname).''; + print ''.dol_escape_htmltag($obj->other).''; print ''; if (empty($obj->source_id) || empty($obj->source_type)) { print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index f4295fa6583..9e10d51031e 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -128,7 +128,8 @@ class FormAdvTargetEmailing extends Form $i++; } - array_multisort($label, SORT_ASC, $countryArray); + $array1_sort_order = SORT_ASC; + array_multisort($label, $array1_sort_order, $countryArray); foreach ($countryArray as $row) { $label = dol_trunc($row['label'], $maxlength, 'middle'); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 588faa392e3..4ea794bfbd4 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -86,6 +86,11 @@ class Mailing extends CommonObject */ public $email_from; + /** + * @var string email to + */ + public $sendto; + /** * @var string email reply to */ @@ -175,6 +180,16 @@ class Mailing extends CommonObject */ public $statuts = array(); + /** + * @var array substitutionarray + */ + public $substitutionarray; + + /** + * @var array substitutionarrayfortest + */ + public $substitutionarrayfortest; + /** * Constructor @@ -713,13 +728,6 @@ class Mailing extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 485b5b0daf9..5e327e1b706 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -50,7 +50,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -124,7 +124,7 @@ $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; $usercancreateintervention = $user->hasRight('ficheinter', 'creer'); -$usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); +$usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php @@ -690,13 +690,13 @@ if (empty($reshook)) { } $deposit = null; - $locationTarget = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $locationTarget = ''; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if ( !$error && GETPOST('statut', 'int') == $object::STATUS_SIGNED && GETPOST('generate_deposit', 'alpha') == 'on' - && ! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer) + && ! empty($deposit_percent_from_payment_terms) && isModEnabled('facture') && !empty($user->rights->facture->creer) ) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; @@ -720,6 +720,7 @@ if (empty($reshook)) { if (!$error) { $db->commit(); + if ($deposit && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $deposit->fetch($deposit->id); // Reload to get new records $outputlangs = $langs; @@ -736,12 +737,15 @@ if (empty($reshook)) { setEventMessages($deposit->error, $deposit->errors, 'errors'); } } + + if ($locationTarget) { + header('Location: ' . $locationTarget); + exit; + } } else { $db->rollback(); + $action = ''; } - - header('Location: ' . $locationTarget); - exit; } } } elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { @@ -897,7 +901,7 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx') ? price2num(GETPOST('tva_tx')) : 0); + $tva_tx = (GETPOST('tva_tx') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; @@ -1518,7 +1522,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); $formmargin = new FormMargin($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -1640,7 +1644,7 @@ if ($action == 'create') { // Ref customer print ''.$langs->trans('RefCustomer').''; - print ''; + print ''; print ''; // Third party @@ -1706,7 +1710,7 @@ if ($action == 'create') { print ''.$langs->trans("ValidityDuration").''.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").''; // Terms of payment - print ''.$langs->trans('PaymentConditionsShort').''; + print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'paiment'); $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); print ''; @@ -1775,7 +1779,7 @@ if ($action == 'create') { print ''; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; @@ -1995,9 +1999,9 @@ if ($action == 'create') { array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); - if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) { + if (!empty($deposit_percent_from_payment_terms) && isModEnabled('facture') && ! empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $object->fetchObjectLinked(); @@ -2207,7 +2211,7 @@ if ($action == 'create') { $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').''; if ($usercancreate) { @@ -2787,7 +2791,7 @@ if ($action == 'create') { } // Create contract - if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->contrat->enabled) && $object->statut == Propal::STATUS_SIGNED) { $langs->load("contracts"); if ($usercancreatecontract) { @@ -2797,7 +2801,7 @@ if ($action == 'create') { // Create an invoice and classify billed if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPOSAL_ARE_NOT_BILLABLE)) { - if (!empty($conf->facture->enabled) && $usercancreateinvoice) { + if (isModEnabled('facture') && $usercancreateinvoice) { print ''.$langs->trans("CreateBill").''; } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 59a03f78bb2..d28b5718c2f 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -135,8 +135,13 @@ class Proposals extends DolibarrApi } // Add external contacts ids. - $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->propal->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->propal->contacts_ids = $tmparray; + } + $this->propal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->propal); } @@ -228,7 +233,10 @@ class Proposals extends DolibarrApi $proposal_static = new Propal($this->db); if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids - $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); + $tmparray = $proposal_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $proposal_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($proposal_static); } $i++; @@ -343,8 +351,8 @@ class Proposals extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->propal->addline( $request_data->desc, @@ -488,8 +496,8 @@ class Proposals extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $propalline = new PropaleLigne($this->db); $result = $propalline->fetch($lineid); @@ -519,7 +527,9 @@ class Proposals extends DolibarrApi isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, - isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice + isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice, + 0, + isset($request_data->rang) ? $request_data->rang : $propalline->rang ); if ($updateRes > 0) { @@ -643,7 +653,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $contacts = $this->invoice->liste_contact(); + $contacts = $this->propal->liste_contact(); foreach ($contacts as $contact) { if ($contact['id'] == $contactid && $contact['code'] == $type) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0d7c301f7b0..1ad6f121848 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -296,8 +296,8 @@ class Propal extends CommonObject 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'position'=>23), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>24), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'datep' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>60), @@ -317,7 +317,7 @@ class Propal extends CommonObject 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), - 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>150), 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Currency', 'enabled'=>1, 'visible'=>-1, 'position'=>155), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>160), 'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>161), @@ -327,7 +327,7 @@ class Propal extends CommonObject 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>180), 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190), - 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>191), + 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>'$conf->stock->enabled', 'visible'=>-1, 'position'=>191), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195), 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205), @@ -490,7 +490,6 @@ class Propal extends CommonObject $line->subprice = -$remise->amount_ht; $line->fk_product = 0; // Id produit predefined $line->qty = 1; - $line->remise = 0; $line->remise_percent = 0; $line->rang = -1; $line->info_bits = 2; @@ -736,7 +735,6 @@ class Propal extends CommonObject // TODO deprecated $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -806,9 +804,10 @@ class Propal extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger + * @param integer $rang line rank * @return int 0 if OK, <0 if KO */ - public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $rang = 0) { global $mysoc, $langs; @@ -894,6 +893,7 @@ class Propal extends CommonObject $line->oldline = $staticline; $this->line = $line; $this->line->context = $this->context; + $this->line->rang = $rang; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { @@ -934,7 +934,6 @@ class Propal extends CommonObject // TODO deprecated $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options @@ -1368,7 +1367,7 @@ class Propal extends CommonObject $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); $object->fk_delivery_address = ''; - /*if (!empty($conf->projet->enabled)) + /*if (!empty($conf->project->enabled)) { $project = new Project($db); if ($this->fk_project > 0 && $project->fetch($this->fk_project)) { @@ -1518,6 +1517,7 @@ class Propal extends CommonObject $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht"; $sql .= ", p.datec"; + $sql .= ", p.date_signature as dates"; $sql .= ", p.date_valid as datev"; $sql .= ", p.datep as dp"; $sql .= ", p.fin_validite as dfv"; @@ -1601,6 +1601,7 @@ class Propal extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date $this->date_modification = $this->db->jdate($obj->date_modification); // tms + $this->date_signature = $this->db->jdate($obj->dates); // Signature date $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); // deprecated $this->fin_validite = $this->db->jdate($obj->dfv); @@ -1898,14 +1899,15 @@ class Propal extends CommonObject // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$i] = $line; - //dol_syslog("1 ".$line->fk_product); - //print "xx $i ".$this->lines[$i]->fk_product; + $i++; } @@ -3991,6 +3993,7 @@ class PropaleLigne extends CommonObjectLine public $multicurrency_total_tva; public $multicurrency_total_ttc; + /** * Class line Contructor * @@ -4130,9 +4133,6 @@ class PropaleLigne extends CommonObjectLine if (empty($this->rang)) { $this->rang = 0; } - if (empty($this->remise)) { - $this->remise = 0; - } if (empty($this->remise_percent) || !is_numeric($this->remise_percent)) { $this->remise_percent = 0; } @@ -4362,9 +4362,6 @@ class PropaleLigne extends CommonObjectLine if (empty($this->price)) { $this->price = 0; // TODO A virer } - if (empty($this->remise)) { - $this->remise = 0; // TODO A virer - } if (empty($this->remise_percent)) { $this->remise_percent = 0; } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 989dcfe7098..d9942e9153c 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -137,7 +137,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->propal->creer) { diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 804fedd623b..31cf2c18f42 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -136,7 +136,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->propal->creer) { diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index dc43af9ceff..65ff9c19e2b 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -28,7 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -83,7 +83,7 @@ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_cl // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->propal->creer) { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index eb5b310edd1..e490a5ca7ac 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -204,8 +204,8 @@ $checkedtypetiers = 0; $arrayfields = array( 'p.ref'=>array('label'=>"Ref", 'checked'=>1), 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1), - 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1)), + 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1), 's.town'=>array('label'=>"Town", 'checked'=>-1), @@ -236,7 +236,7 @@ $arrayfields = array( 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>-1), - 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), @@ -377,14 +377,14 @@ if ($action == 'validate' && $permissiontovalidate) { if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) { if ($tmpproposal->valid($user) > 0) { - setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs'); + setEventMessages($langs->trans('hasBeenValidated', $tmpproposal->ref), null, 'mesgs'); } else { - setEventMessage($tmpproposal->error, $tmpproposal->errors, 'errors'); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $tmpproposal->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $tmpproposal->ref), null, 'errors'); $error++; } } else { @@ -410,7 +410,7 @@ if ($action == "sign" && $permissiontoclose) { if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { $tmpproposal->statut = $tmpproposal::STATUS_SIGNED; if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) { - setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); + setEventMessages($tmpproposal->ref." ".$langs->trans('Signed'), null, 'mesgs'); } else { setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; @@ -765,12 +765,12 @@ if ($resql) { if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfProposals').' - '.$soc->name; + $title = $langs->trans('Proposals').' - '.$soc->name; if (empty($search_societe)) { $search_societe = $soc->name; } } else { - $title = $langs->trans('ListOfProposals'); + $title = $langs->trans('Proposals'); } $num = $db->num_rows($resql); @@ -2133,7 +2133,7 @@ if ($resql) { $totalarray['nbfield']++; } - print "\n"; + print ''."\n"; $i++; } @@ -2141,6 +2141,17 @@ if ($resql) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; + } + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 13fa42edb29..7e40552fefb 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -107,7 +107,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->propal->creer) { diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 0a182e6dcbe..576285594b4 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -335,11 +335,11 @@ foreach ($data as $val) { print ''; print ' 0 ? '&userid='.$userid : '').'">'.$year.''; print ''.$val['nb'].''; - print ''.round($val['nb_diff']).'%'; + print ''.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%'; print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.round($val['total_diff']).'%'; + print ''.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%'; print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''.round($val['avg_diff']).'%'; + print ''.(isset($val['avg_diff']) ? round($val['avg_diff']) : "0").'%'; print ''; $oldyear = $year; } diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 0bcf2662a44..e63aee6f240 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -169,7 +169,7 @@ print '
'; /* * Actions commerciales a faire */ -if (!empty($conf->agenda->enabled)) { +if (isModEnabled('agenda')) { show_array_actions_to_do(10); } diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index ee32c0dd016..da37fe1048c 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page $langs->load("companies"); -if (!empty($conf->facture->enabled)) { +if (isModEnabled('facture')) { $langs->load("bills"); } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index c0e96aa4b15..f36b4bb0b9e 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -284,11 +284,11 @@ if ($socid > 0) { } print ''.$langs->trans("CustomerAbsoluteDiscountAllUsers").''; - print ''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; + print ''.price($remise_all, 1, $langs, 1, -1, -1, $conf->currency).' '.$langs->trans("HT").''; if (!empty($user->fk_soc)) { // No need to show this for external users print ''.$langs->trans("CustomerAbsoluteDiscountMy").''; - print ''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; + print ''.price($remise_user, 1, $langs, 1, -1, -1, $conf->currency).' '.$langs->trans("HT").''; } } @@ -314,11 +314,11 @@ if ($socid > 0) { } print ''.$langs->trans("SupplierAbsoluteDiscountAllUsers").''; - print ''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; + print ''.price($remise_all, 1, $langs, 1, -1, -1, $conf->currency).' '.$langs->trans("HT").''; if (!empty($user->fk_soc)) { // No need to show this for external users print ''.$langs->trans("SupplierAbsoluteDiscountMy").''; - print ''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; + print ''.price($remise_user, 1, $langs, 1, -1, -1, $conf->currency).' '.$langs->trans("HT").''; } } @@ -353,7 +353,7 @@ if ($socid > 0) { print ''; } print ''.$langs->trans("AmountHT").''; - print ''; + print ''; print ' '.$langs->trans("Currency".$conf->currency).''; print ''.$langs->trans("VAT").''; print ''; @@ -382,7 +382,7 @@ if ($socid > 0) { print '
'; - if ($_GET['action'] == 'remove') { + if ($action == 'remove') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.GETPOST('remid'), $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1); } @@ -445,7 +445,7 @@ if ($socid > 0) { $obj = $db->fetch_object($resql); print ''; - print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; + print ''.dol_print_date($db->jdate($obj->dc), 'dayhour', 'tzuserrel').''; if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; $facturestatic->id = $obj->fk_facture_source; @@ -472,15 +472,15 @@ if ($socid > 0) { print $obj->description; print ''; } - print ''.$langs->trans("NotConsumed").''; - print ''.price($obj->amount_ht).''; + print ''.$langs->trans("NotConsumed").''; + print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ht).''; + print ''.price($obj->multicurrency_amount_ht).''; } print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; - print ''.price($obj->amount_ttc).''; + print ''.price($obj->amount_ttc).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ttc).''; + print ''.price($obj->multicurrency_amount_ttc).''; } print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; @@ -583,7 +583,7 @@ if ($socid > 0) { $obj = $db->fetch_object($resql); print ''; - print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; + print ''.dol_print_date($db->jdate($obj->dc), 'dayhour', 'tzuserrel').''; if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; @@ -610,15 +610,15 @@ if ($socid > 0) { print $obj->description; print ''; } - print ''.$langs->trans("NotConsumed").''; - print ''.price($obj->amount_ht).''; + print ''.$langs->trans("NotConsumed").''; + print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ht).''; + print ''.price($obj->multicurrency_amount_ht).''; } print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; - print ''.price($obj->amount_ttc).''; + print ''.price($obj->amount_ttc).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ttc).''; + print ''.price($obj->multicurrency_amount_ttc).''; } print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; @@ -766,7 +766,8 @@ if ($socid > 0) { $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } $db->free($resql2); - array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); + $array1_sort_order = SORT_DESC; + array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj); $num = count($tab_sqlobj); if ($num > 0) { @@ -926,7 +927,8 @@ if ($socid > 0) { $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } $db->free($resql2); - array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); + $array1_sort_order = SORT_DESC; + array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj); $num = count($tab_sqlobj); if ($num > 0) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1a35ff937b9..a3d1fa2da04 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -48,7 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (!empty($conf->propal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -1177,14 +1177,14 @@ if (empty($reshook)) { } if (!$error) { - $locationTarget = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $locationTarget = ''; $db->begin(); $result = $object->valid($user, $idwarehouse); if ($result >= 0) { $error = 0; $deposit = null; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if ( GETPOST('generate_deposit', 'alpha') == 'on' && ! empty($deposit_percent_from_payment_terms) @@ -1205,6 +1205,7 @@ if (empty($reshook)) { setEventMessage('DepositGenerated'); $locationTarget = DOL_URL_ROOT . '/compta/facture/card.php?id=' . $deposit->id; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1236,6 +1237,11 @@ if (empty($reshook)) { $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } + + if ($locationTarget) { + header('Location: ' . $locationTarget); + exit; + } } else { $db->rollback(); } @@ -1243,9 +1249,6 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - - header('Location: ' . $locationTarget); - exit; } } elseif ($action == 'confirm_modif' && $usercancreate) { // Go back to draft status @@ -1489,7 +1492,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $formmargin = new FormMargin($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -1694,8 +1697,8 @@ if ($action == 'create' && $usercancreate) { if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). print "".$langs->trans("DefaultContact").''; - print img_picto('', 'contact'); - print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); + print img_picto('', 'contact', 'class="pictofixedwidth"'); + print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; // Ligne info remises tiers @@ -1730,10 +1733,10 @@ if ($action == 'create' && $usercancreate) { $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; - // Terms of the settlement + // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment', 'class="pictofixedwidth"'); - $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', $deposit_percent); + print img_picto('', 'payment', 'class="pictofixedwidth"'); + $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); print ''; // Payment mode @@ -1750,10 +1753,9 @@ if ($action == 'create' && $usercancreate) { } // Shipping Method - if (!empty($conf->expedition->enabled)) { + if (isModEnabled('expedition')) { print ''.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); - print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -1775,7 +1777,7 @@ if ($action == 'create' && $usercancreate) { // TODO How record was recorded OrderMode (llx_c_input_method) // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; @@ -1833,7 +1835,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; - print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -2022,7 +2024,7 @@ if ($action == 'create' && $usercancreate) { if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; @@ -2243,7 +2245,7 @@ if ($action == 'create' && $usercancreate) { $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($usercancreate) { @@ -2380,7 +2382,7 @@ if ($action == 'create' && $usercancreate) { print ''; // Shipping Method - if (!empty($conf->expedition->enabled)) { + if (isModEnabled('expedition')) { print ''; $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); @@ -2732,7 +2734,7 @@ if ($action == 'create' && $usercancreate) { } // Create intervention - if ($conf->ficheinter->enabled) { + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { @@ -2745,7 +2747,7 @@ if ($action == 'create' && $usercancreate) { } // Create contract - if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { + if (!empty($conf->contrat->enabled) && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { $langs->load("contracts"); if ($user->rights->contrat->creer) { @@ -2755,11 +2757,11 @@ if ($action == 'create' && $usercancreate) { // Ship $numshipping = 0; - if (!empty($conf->expedition->enabled)) { + if (isModEnabled('expedition')) { $numshipping = $object->nb_expedition(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { + if ((isModEnabled('expedition_bon') && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { if ($user->rights->expedition->creer) { print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, ''); } else { @@ -2779,7 +2781,7 @@ if ($action == 'create' && $usercancreate) { // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) { - if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { + if (isModEnabled('facture') && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 17528001d1b..2c916abda9a 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -133,7 +133,10 @@ class Orders extends DolibarrApi } // Add external contacts ids - $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->commande->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->commande->contacts_ids = $tmparray; + } $this->commande->fetchObjectLinked(); // Add online_payment_url, cf #20477 @@ -234,7 +237,10 @@ class Orders extends DolibarrApi $commande_static = new Commande($this->db); if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids - $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); + $tmparray = $commande_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $commande_static->contacts_ids = $tmparray; + } // Add online_payment_url, cf #20477 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; $commande_static->online_payment_url = getOnlinePaymentUrl(0, 'order', $commande_static->ref); @@ -344,8 +350,8 @@ class Orders extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->commande->addline( $request_data->desc, @@ -412,8 +418,8 @@ class Orders extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->commande->updateline( $lineid, @@ -439,7 +445,8 @@ class Orders extends DolibarrApi $request_data->fk_unit, $request_data->multicurrency_subprice, 0, - $request_data->ref_ext + $request_data->ref_ext, + $request_data->rang ); if ($updateRes > 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ca149d1f681..3427e38d99e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -313,8 +313,8 @@ class Commande extends CommonOrder 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>25), 'date_commande' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>1, 'position'=>60), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>62), 'date_cloture' =>array('type'=>'datetime', 'label'=>'DateClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>65), @@ -334,14 +334,14 @@ class Commande extends CommonOrder 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>155), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>160), //'facture' =>array('type'=>'tinyint(4)', 'label'=>'ParentInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>165), - 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>170), + 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>170), 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'MulticurrencyID', 'enabled'=>1, 'visible'=>-1, 'position'=>175), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>180), 'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>181), 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>190), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>195), - 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>200), + 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>'$conf->stock->enabled', 'visible'=>-1, 'position'=>200), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>205), 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>210), //'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>-1, 'position'=>215), @@ -359,7 +359,7 @@ class Commande extends CommonOrder 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'POSTerminal', 'enabled'=>1, 'visible'=>-1, 'position'=>280), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>300), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>302), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>304), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>304), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>306), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>400), 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'position'=>500), @@ -1666,7 +1666,6 @@ class Commande extends CommonOrder // TODO Ne plus utiliser $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -2010,7 +2009,6 @@ class Commande extends CommonOrder $line->price = -$remise->amount_ht; $line->fk_product = 0; // Id produit predefini $line->qty = 1; - $line->remise = 0; $line->remise_percent = 0; $line->rang = -1; $line->info_bits = 2; @@ -2125,9 +2123,9 @@ class Commande extends CommonOrder $line->product_ref = $objp->product_ref; $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; $line->product_tosell = $objp->product_tosell; $line->product_tobuy = $objp->product_tobuy; + $line->product_desc = $objp->product_desc; $line->product_tobatch = $objp->product_tobatch; $line->product_barcode = $objp->product_barcode; @@ -2154,9 +2152,11 @@ class Commande extends CommonOrder // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$i] = $line; @@ -3087,9 +3087,10 @@ class Commande extends CommonOrder * @param double $pu_ht_devise Amount in currency * @param int $notrigger disable line update trigger * @param string $ref_ext external reference + * @param integer $rang line rank * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $mysoc, $langs, $user; @@ -3214,6 +3215,7 @@ class Commande extends CommonOrder $line->oldline = $staticline; $this->line = $line; $this->line->context = $this->context; + $this->line->rang = $rang; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { @@ -3260,7 +3262,6 @@ class Commande extends CommonOrder // TODO deprecated $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options @@ -4402,9 +4403,6 @@ class OrderLine extends CommonOrderLine if (empty($this->rang)) { $this->rang = 0; } - if (empty($this->remise)) { - $this->remise = 0; - } if (empty($this->remise_percent)) { $this->remise_percent = 0; } @@ -4445,7 +4443,7 @@ class OrderLine extends CommonOrderLine $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; $sql .= ' (fk_commande, fk_parent_line, label, description, qty, ref_ext,'; $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql .= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, price, fk_remise_except,'; $sql .= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; $sql .= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,'; $sql .= ' fk_unit'; @@ -4468,7 +4466,6 @@ class OrderLine extends CommonOrderLine $sql .= " '".price2num($this->remise_percent)."',"; $sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").","; $sql .= " ".($this->price != '' ? "'".price2num($this->price)."'" : "null").","; - $sql .= " '".price2num($this->remise)."',"; $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; $sql .= ' '.((int) $this->special_code).','; $sql .= ' '.((int) $this->rang).','; @@ -4577,9 +4574,6 @@ class OrderLine extends CommonOrderLine if (empty($this->marge_tx)) { $this->marge_tx = 0; } - if (empty($this->remise)) { - $this->remise = 0; - } if (empty($this->remise_percent)) { $this->remise_percent = 0; } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index b89623fc3a0..5f4de8b59a0 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->commande->creer) { diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 684d8e61334..d85400243e7 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -130,7 +130,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->commande->creer) { diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 38d8beba2ec..93b80b80f1c 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -27,7 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -83,7 +83,7 @@ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_cl // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->commande->creer) { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b2bf9615d17..350674370e9 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -165,8 +165,8 @@ $checkedtypetiers = 0; $arrayfields = array( 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>20), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>25), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>25), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), @@ -190,7 +190,7 @@ $arrayfields = array( 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), - 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), @@ -1015,12 +1015,12 @@ if ($resql) { if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfOrders').' - '.$soc->name; + $title = $langs->trans('CustomersOrders').' - '.$soc->name; if (empty($search_company)) { $search_company = $soc->name; } } else { - $title = $langs->trans('ListOfOrders'); + $title = $langs->trans('CustomersOrders'); } if (strval($search_status) == '0') { $title .= ' - '.$langs->trans('StatusOrderDraftShort'); @@ -1821,8 +1821,9 @@ if ($resql) { $total_ht = 0; $total_margin = 0; + $imaxinloop = ($limit ? min($num, $limit) : $num); $last_num = min($num, $limit); - while ($i < $last_num) { + while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); $notshippable = 0; @@ -1928,7 +1929,7 @@ if ($resql) { print $getNomUrl_cache[$obj->socid]; // If module invoices enabled and user with invoice creation permissions - if (!empty($conf->facture->enabled) && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { + if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { if ($user->rights->facture->creer) { if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { print ' '; @@ -2457,6 +2458,17 @@ if ($resql) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; + } + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 55140c30ae2..75d8e587ccb 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -28,7 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -102,7 +102,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->commande->creer) { diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 603627ee91e..3e33ddedf57 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -394,11 +394,11 @@ foreach ($data as $val) { print ''; print '
0 ? '&userid='.$userid : '').'">'.$year.''; print ''.$val['nb'].''; - print ''.round($val['nb_diff']).'%'; + print ''.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%'; print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.round($val['total_diff']).'%'; + print ''.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%'; print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''.round($val['avg_diff']).'%'; + print ''.(isset($val['avg_diff']) ? round($val['avg_diff']) : "0").'%'; print ''; $oldyear = $year; } diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 8f61261bc11..996ad22fbce 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -127,7 +127,7 @@ if (empty($entity)) { $error = 0; $listofchoices = array( - 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => !empty($conf->facture->enabled), 'perms' => !empty($user->rights->facture->lire)), + 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => !empty($user->rights->facture->lire)), 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => !empty($conf->supplier_invoice->enabled), 'perms' => !empty($user->rights->fournisseur->facture->lire)), 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips', 'enabled' => !empty($conf->expensereport->enabled), 'perms' => !empty($user->rights->expensereport->lire)), 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation', 'enabled' => !empty($conf->don->enabled), 'perms' => !empty($user->rights->don->lire)), diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 36a9d17315a..5d6c2045d47 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Charles-Fr BENKE +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 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 @@ -78,6 +78,9 @@ if (!empty($ref)) { $id = $object->id; } +$annee = ''; +$totentrees = array(); +$totsorties = array(); // Ce rapport de tresorerie est base sur llx_bank (car doit inclure les transactions sans facture) // plutot que sur llx_paiement + llx_paiementfourn @@ -192,14 +195,14 @@ for ($mois = 1; $mois < 13; $mois++) { $case = sprintf("%04s-%02s", $annee, $mois); print ' '; - if ($decaiss[$case] > 0) { + if (isset($decaiss[$case]) && $decaiss[$case] > 0) { print price($decaiss[$case]); $totsorties[$annee] += $decaiss[$case]; } print ""; print ' '; - if ($encaiss[$case] > 0) { + if (isset($encaiss[$case]) && $encaiss[$case] > 0) { print price($encaiss[$case]); $totentrees[$annee] += $encaiss[$case]; } @@ -211,7 +214,8 @@ for ($mois = 1; $mois < 13; $mois++) { // Total debit-credit print ''.$langs->trans("Total").""; for ($annee = $year_start; $annee <= $year_end; $annee++) { - print ''.price($totsorties[$annee]).''.price($totentrees[$annee]).''; + print ''. (isset($totsorties[$annee]) ? price($totsorties[$annee]) : '') .''; + print ''. (isset($totentrees[$annee]) ? price($totentrees[$annee]) : '') .''; } print "\n"; @@ -245,6 +249,7 @@ if ($resql) { print ''; +$nbcol = ''; print '"; print ''; print "\n"; @@ -267,7 +272,7 @@ if ($result < 0) { $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($id && $_GET["option"] != 'all') { + if ($id && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($id).")"; } @@ -299,7 +304,7 @@ if ($result < 0) { $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; $sql .= " AND b.amount > 0"; - if ($id && $_GET["option"] != 'all') { + if ($id && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($id).")"; } $sql .= " GROUP BY date_format(b.datev,'%m');"; @@ -381,7 +386,7 @@ if ($result < 0) { $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; $sql .= " AND b.amount < 0"; - if ($id && $_GET["option"] != 'all') { + if ($id && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($id).")"; } $sql .= " GROUP BY date_format(b.datev,'%m');"; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 05b30d69668..fba2d05897c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -32,14 +32,15 @@ */ require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; @@ -54,6 +55,7 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "bills", "categories", "companies", "margins", "salaries", "loan", "donations", "trips", "members", "compta", "accountancy")); @@ -99,6 +101,7 @@ $search_thirdparty_user = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search $search_req_nb = GETPOST("req_nb", 'alpha'); $search_num_releve = GETPOST("search_num_releve", 'alpha'); $search_conciliated = GETPOST("search_conciliated", 'int'); +$search_fk_bordereau = GETPOST("search_fk_bordereau", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $toselect = GETPOST('toselect', 'array'); $num_releve = GETPOST("num_releve", "alpha"); @@ -157,20 +160,21 @@ $extrafields->fetch_name_optionals_label('banktransaction'); $search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1), - 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), - 'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>500), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000), - 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), - 'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000), - 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001), - 'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010), - 'b.conciliated'=>array('label'=>$langs->trans("BankLineReconciled"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1,'position'=>10), + 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1,'position'=>20), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1,'position'=>30), + 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1,'position'=>40), + 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1,'position'=>50), + 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1,'position'=>60), + 'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>70), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>80), + 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>90), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>100), + 'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>110), + 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>120), + 'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>130), + 'b.conciliated'=>array('label'=>$langs->trans("BankLineReconciled"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>140), + 'b.fk_bordereau'=>array('label'=>$langs->trans("ChequeReceipt"), 'checked'=>0, 'position'=>150), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -178,7 +182,6 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - /* * Actions */ @@ -214,6 +217,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_thirdparty_user = ''; $search_num_releve = ''; $search_conciliated = ''; + $search_fk_bordereau = ''; $toselect = array(); $search_account = ""; @@ -390,8 +394,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && !empty($user->rights->ba } } - - /* * View */ @@ -421,6 +423,7 @@ $paymentvariousstatic = new PaymentVarious($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); $bankstatic = new Account($db); $banklinestatic = new AccountLine($db); +$bordereaustatic = new RemiseCheque($db); $now = dol_now(); @@ -465,6 +468,9 @@ if (!empty($search_num_releve)) { if ($search_conciliated != '' && $search_conciliated != '-1') { $param .= '&search_conciliated='.urlencode($search_conciliated); } +if ($search_fk_bordereau > 0) { + $param .= '$&search_fk_bordereau='.urlencode($search_fk_bordereau); +} if ($search_bid > 0) { $param .= '&search_bid='.urlencode($search_bid); } @@ -547,7 +553,7 @@ if ($id > 0 || !empty($ref)) { if ($user->rights->banque->consolidate) { $newparam = $param; $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam); - $buttonreconcile = ''.$titletoconciliatemanual.''; + $buttonreconcile = ''.$titletoconciliatemanual.''; } else { $buttonreconcile = ''.$titletoconciliatemanual.''; } @@ -557,7 +563,7 @@ if ($id > 0 || !empty($ref)) { if ($user->rights->banque->consolidate) { $newparam = $param; $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam); - $buttonreconcile .= ' '.$titletoconciliateauto.''; + $buttonreconcile .= ' '.$titletoconciliateauto.''; } else { $buttonreconcile .= ' '.$titletoconciliateauto.''; } @@ -568,8 +574,9 @@ if ($id > 0 || !empty($ref)) { llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); } + $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; -$sql .= " b.fk_account, b.fk_type,"; +$sql .= " b.fk_account, b.fk_type, b.fk_bordereau,"; $sql .= " ba.rowid as bankid, ba.ref as bankref"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -621,6 +628,9 @@ if ($search_num_releve) { if ($search_conciliated != '' && $search_conciliated != '-1') { $sql .= " AND b.rappro = ".((int) $search_conciliated); } +if ($search_fk_bordereau > 0) { + $sql .= " AND b.fk_bordereau = " . ((int) $search_fk_bordereau); +} if ($search_thirdparty_user) { $sql.= " AND (b.rowid IN "; $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu"; @@ -737,6 +747,9 @@ if ($search_conciliated != '' && $search_conciliated != '-1') { if (!empty($search_num_releve)) { $mode_balance_ok = false; } +if (!empty($search_fk_bordereau)) { + $mode_balance_ok = false; +} $sql .= $db->plimit($limit + 1, $offset); //print $sql; @@ -1067,34 +1080,40 @@ if ($resql) { $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100'); print ''; } + // Numero if (!empty($arrayfields['b.num_chq']['checked'])) { - // Numero print ''; } + // Checked if (!empty($arrayfields['bu.label']['checked'])) { print ''; } + // Ref if (!empty($arrayfields['ba.ref']['checked'])) { print ''; } + // Debit if (!empty($arrayfields['b.debit']['checked'])) { print ''; } + // Credit if (!empty($arrayfields['b.credit']['checked'])) { print ''; } + // Balance before if (!empty($arrayfields['balancebefore']['checked'])) { print ''; } + // Balance if (!empty($arrayfields['balance']['checked'])) { print ''; } + // Bordereau + if (!empty($arrayfields['b.fk_bordereau']['checked'])) { + print ''; + } + // Actions and select print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action edit/delete and select print ''; // Tags-Categories - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { print ''; @@ -540,7 +541,7 @@ if ($action == 'create') { print ''; print ''; - if ($conf->paymentbybanktransfer->enabled) { + if (isModEnabled('paymentbybanktransfer')) { print ''; print ''; + } - $db->free($result); + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print '
'.$langs->trans("CurrentBalance")."'.price($balance).'
'; $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100'); print ''; print ''; print ''; print ''; print ''; $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue")); print $form->textwithpicto('', $htmltext, 1); print ''; $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue")); @@ -1111,6 +1130,11 @@ if ($resql) { print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1); print ''; $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); @@ -1162,6 +1186,10 @@ if ($resql) { if (!empty($arrayfields['b.conciliated']['checked'])) { print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center "); } + if (!empty($arrayfields['b.fk_bordereau']['checked'])) { + print_liste_field_titre($arrayfields['b.fk_bordereau']['label'], $_SERVER['PHP_SELF'], 'b.fk_bordereau', '', $param, '', $sortfield, $sortorder, "center "); + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -1673,6 +1701,16 @@ if ($resql) { } } + if (!empty($arrayfields['b.fk_bordereau']['checked'])) { + $bordereaustatic->fetch($objp->fk_bordereau); + print ''; + print $bordereaustatic->getNomUrl(); + print ''; // Transaction reconciliated or edit link diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 495dd86f268..31a918b1a27 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * Copyright (C) 2018 Frédéric France + * Copyright (C) 2022 Charlene 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 @@ -124,11 +125,11 @@ if (empty($reshook)) { $object->cle_rib = trim(GETPOST("cle_rib")); $object->bic = trim(GETPOST("bic")); $object->iban = trim(GETPOST("iban")); - $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); + $object->domiciliation = trim(GETPOST("domiciliation", "alphanohtml")); $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1; $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); - $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); + $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml')); $object->ics = trim(GETPOST("ics", 'alpha')); $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha')); @@ -225,11 +226,11 @@ if (empty($reshook)) { $object->cle_rib = trim(GETPOST("cle_rib")); $object->bic = trim(GETPOST("bic")); $object->iban = trim(GETPOST("iban")); - $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); + $object->domiciliation = trim(GETPOST("domiciliation", "alphanohtml")); $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1; $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); - $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); + $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml')); $object->ics = trim(GETPOST("ics", 'alpha')); $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha')); @@ -436,7 +437,7 @@ if ($action == 'create') { print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); @@ -457,7 +458,7 @@ if ($action == 'create') { print ''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_4, '90%'); $doleditor->Create(); print '
'.$langs->trans($bickey).'
'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").' '; print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info'); @@ -713,7 +714,7 @@ if ($action == 'create') { print ''; // Categories - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { print '"; @@ -777,14 +778,14 @@ if ($action == 'create') { } print ''; - if ($conf->prelevement->enabled) { + if (isModEnabled('prelevement')) { print ''; print ''; print ''; } // TODO ICS is not used with bank transfer ! - if ($conf->paymentbybanktransfer->enabled) { + if (isModEnabled('paymentbybanktransfer')) { print ''; print ''; print ''; @@ -966,7 +967,7 @@ if ($action == 'create') { print ''; // Tags-Categories - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { print ''; print ''; - if ($conf->prelevement->enabled) { + if (isModEnabled('prelevement')) { print ''; print ''; } - if ($conf->paymentbybanktransfer->enabled) { + if (!empty(isModEnabled('paymentbybanktransfer'))) { print ''; print ''; diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 2605bc39d30..aa60c1ddf41 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -113,7 +113,7 @@ if ($action != 'edit') { print ''; print ''; print ''; - print ''; + print ''; print ''; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 429d7c704c8..13fdffcb3c9 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -145,6 +145,12 @@ class Account extends CommonObject */ public $iban_prefix; + /** + * Address of the bank + * @var string + */ + public $domiciliation; + /** * XML SEPA format: place Payment Type Information (PmtTpInf) in Credit Transfer Transaction Information (CdtTrfTxInf) * @var int @@ -1200,7 +1206,7 @@ class Account extends CommonObject * Return current sold * * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) - * @param tms $date_end Date until we want to get bank account sold + * @param int $date_end Date until we want to get bank account sold * @param string $field dateo or datev * @return int current sold (value date <= today) */ diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 23d4c2eefbb..8e38d1ffe78 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -250,7 +250,7 @@ class BankAccounts extends DolibarrApi } // Clean data - $description = checkVal($description, 'alphanohtml'); + $description = sanitizeVal($description, 'alphanohtml'); /** @@ -498,13 +498,13 @@ class BankAccounts extends DolibarrApi throw new RestException(404, 'account not found'); } - $type = checkVal($type); - $label = checkVal($label); - $cheque_number = checkVal($cheque_number); - $cheque_writer = checkVal($cheque_writer); - $cheque_bank = checkVal($cheque_bank); - $accountancycode = checkVal($accountancycode); - $num_releve = checkVal($num_releve); + $type = sanitizeVal($type); + $label = sanitizeVal($label); + $cheque_number = sanitizeVal($cheque_number); + $cheque_writer = sanitizeVal($cheque_writer); + $cheque_bank = sanitizeVal($cheque_bank); + $accountancycode = sanitizeVal($accountancycode); + $num_releve = sanitizeVal($num_releve); $result = $account->addline( $date, @@ -557,9 +557,9 @@ class BankAccounts extends DolibarrApi throw new RestException(404, 'account line not found'); } - $url = checkVal($url); - $label = checkVal($label); - $type = checkVal($type); + $url = sanitizeVal($url); + $label = sanitizeVal($label); + $type = sanitizeVal($type); $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); if ($result < 0) { diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index cdcd26490a3..8bad5dbebd0 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -165,7 +165,7 @@ class PaymentVarious extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->element = 'payment_various'; @@ -694,13 +694,6 @@ class PaymentVarious extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 4c0efec57d2..459134dc68a 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -95,7 +95,7 @@ if ($result < 0) { $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } @@ -137,7 +137,7 @@ if ($result < 0) { $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.datev >= '".$db->escape($year)."-".$db->escape($month)."-01 00:00:00'"; $sql .= " AND b.datev < '".$db->escape($yearnext)."-".$db->escape($monthnext)."-01 00:00:00'"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; @@ -165,7 +165,7 @@ if ($result < 0) { $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.datev < '".$db->escape($year)."-".sprintf("%02s", $month)."-01'"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } @@ -279,7 +279,7 @@ if ($result < 0) { $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.datev >= '".$db->escape($year)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".$db->escape($year)."-12-31 23:59:59'"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; @@ -307,7 +307,7 @@ if ($result < 0) { $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.datev < '".$db->escape($year)."-01-01'"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } @@ -415,7 +415,7 @@ if ($result < 0) { $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; @@ -540,7 +540,7 @@ if ($result < 0) { $sql .= " AND b.datev >= '".$db->escape($year)."-".$db->escape($month)."-01 00:00:00'"; $sql .= " AND b.datev < '".$db->escape($yearnext)."-".$db->escape($monthnext)."-01 00:00:00'"; $sql .= " AND b.amount > 0"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%d')"; @@ -575,7 +575,7 @@ if ($result < 0) { $sql .= " AND b.datev >= '".$db->escape($year)."-".$db->escape($month)."-01 00:00:00'"; $sql .= " AND b.datev < '".$db->escape($yearnext)."-".$db->escape($monthnext)."-01 00:00:00'"; $sql .= " AND b.amount < 0"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%d')"; @@ -649,7 +649,7 @@ if ($result < 0) { $sql .= " AND b.datev >= '".$db->escape($year)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".$db->escape($year)."-12-31 23:59:59'"; $sql .= " AND b.amount > 0"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%m');"; @@ -676,7 +676,7 @@ if ($result < 0) { $sql .= " AND b.datev >= '".$db->escape($year)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".$db->escape($year)."-12-31 23:59:59'"; $sql .= " AND b.amount < 0"; - if ($account && $_GET["option"] != 'all') { + if ($account && GETPOST("option") != 'all') { $sql .= " AND b.fk_account IN (".$db->sanitize($account).")"; } $sql .= " GROUP BY date_format(b.datev,'%m')"; @@ -748,7 +748,7 @@ if ($account) { if (!preg_match('/,/', $account)) { $moreparam = '&month='.$month.'&year='.$year.($mode == 'showalltime' ? '&mode=showalltime' : ''); - if ($_GET["option"] != 'all') { + if (GETPOST("option") != 'all') { $morehtml = ''.$langs->trans("ShowAllAccounts").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); } else { diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index bc70d27ba70..3cde5212e2d 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -52,11 +52,12 @@ if (!empty($conf->salaries->enabled)) { $id = GETPOST('rowid', 'int'); -$accountid = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); +$rowid = GETPOST("rowid", 'int'); +$accountoldid = GETPOST('account', 'int'); // GETPOST('account') is old account id +$accountid = GETPOST('accountid', 'int'); // GETPOST('accountid') is new account id $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$rowid = GETPOST("rowid", 'int'); $orig_account = GETPOST("orig_account"); $backtopage = GETPOST('backtopage', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -69,7 +70,7 @@ if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', $accountid, 'bank_account'); +$result = restrictedArea($user, 'banque', $accountoldid, 'bank_account'); if (empty($user->rights->banque->lire) && empty($user->rights->banque->consolidate)) { accessforbidden(); } @@ -124,18 +125,26 @@ if ($user->rights->banque->modifier && $action == "update") { $error = 0; $acline = new AccountLine($db); - $acline->fetch($rowid); + $result = $acline->fetch($rowid); + if ($result <= 0) { + dol_syslog('Failed to read bank line with id '.$rowid, LOG_WARNING); // This happens due to old bug that has set fk_account to null. + $acline->id = $rowid; + } $acsource = new Account($db); - $acsource->fetch($id); + $acsource->fetch($accountoldid); $actarget = new Account($db); if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) { // We ask to change bank account $actarget->fetch(GETPOST('accountid', 'int')); } else { - $actarget->fetch($id); + $actarget->fetch($accountoldid); } + if (!($actarget->id > 0)) { + setEventMessages($langs->trans("ErrorFailedToLoadBankAccount"), null, 'errors'); + $error++; + } if ($actarget->courant == Account::TYPE_CASH && GETPOST('value', 'alpha') != 'LIQ') { setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors'); $error++; @@ -229,7 +238,7 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); + $sql .= " SET num_releve = ".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); if (empty($num_rel)) { $sql .= ", rappro = 0"; } else { @@ -307,7 +316,6 @@ if ($result) { print ''; print ''; print ''; - print ''; print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); @@ -326,11 +334,12 @@ if ($result) { // Bank account print ''; print ''; print ''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 19b47430fad..238b9919ef1 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -534,7 +534,7 @@ foreach ($accounts as $key => $type) { // Ref if (!empty($arrayfields['b.ref']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -550,7 +550,7 @@ foreach ($accounts as $key => $type) { // Account type if (!empty($arrayfields['accountype']['checked'])) { - print ''; if (!$i) { @@ -586,7 +586,7 @@ foreach ($accounts as $key => $type) { // Accountancy journal if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - print ''; if (!$i) { @@ -616,9 +616,18 @@ foreach ($accounts as $key => $type) { // Transactions to reconcile if (!empty($arrayfields['toreconcile']['checked'])) { - print ''; if (!$i) { @@ -672,7 +681,7 @@ foreach ($accounts as $key => $type) { } // Date modification if (!empty($arrayfields['b.tms']['checked'])) { - print ''; if (!$i) { diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 2385f2210a5..d424a3a8fef 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -1,10 +1,11 @@ - * Copyright (C) 2004-2019 Laurent Destailleur - * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2017 Patrick Delcroix - * Copyright (C) 2019 Nicolas ZABOURI +/* Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Patrick Delcroix + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2022 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 @@ -57,6 +58,8 @@ $ve = GETPOST("ve", 'alpha'); $brref = GETPOST('brref', 'alpha'); $oldbankreceipt = GETPOST('oldbankreceipt', 'alpha'); $newbankreceipt = GETPOST('newbankreceipt', 'alpha'); +$rel = GETPOST("rel", 'alphanohtml'); +$backtopage = GETPOST('backtopage', 'alpha'); // Security check $fieldid = (!empty($ref) ? $ref : $id); @@ -112,7 +115,7 @@ $contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id // Define number of receipt to show (current, previous or next one ?) $found = false; -if ($_GET["rel"] == 'prev') { +if ($rel == 'prev') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -130,7 +133,7 @@ if ($_GET["rel"] == 'prev') { $found = true; } } -} elseif ($_GET["rel"] == 'next') { +} elseif ($rel == 'next') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -237,10 +240,10 @@ if (empty($numref)) { $sql .= $db->order($sortfield, $sortorder); // Count total nb of records - $nbtotalofrecords = ''; + $totalnboflines = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $totalnboflines = $db->num_rows($result); } $sql .= $db->plimit($conf->liste_limit + 1, $offset); @@ -276,7 +279,7 @@ if (empty($numref)) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - $buttonreconcile = ''.$titletoconciliatemanual.''; + $buttonreconcile = ''.$titletoconciliatemanual.''; } else { $buttonreconcile = ''.$titletoconciliatemanual.''; } @@ -287,7 +290,7 @@ if (empty($numref)) { if ($user->rights->banque->consolidate) { $newparam = $param; $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam); - $buttonreconcile .= ' '.$titletoconciliateauto.''; + $buttonreconcile .= ' '.$titletoconciliateauto.''; } else { $buttonreconcile .= ' '.$titletoconciliateauto.''; } @@ -399,9 +402,8 @@ if (empty($numref)) { $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, $morehtmlright, ''); - //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1); - print "
"; + print ''; print ''; print ''; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 98a51947c0e..71e5cf37c87 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -1,8 +1,8 @@ - * Copyright (C) 2008-2009 Laurent Destailleur (Eldy) - * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2015 Marcos García + * Copyright (C) 2008-2009 Laurent Destailleur (Eldy) + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -185,7 +185,7 @@ if (GETPOST("account") || GETPOST("ref")) { $solde = $object->solde(0); - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { + if (getDolGlobalInt('MULTICOMPANY_INVOICE_SHARING_ENABLED')) { $colspan = 6; } else { $colspan = 5; @@ -199,7 +199,7 @@ if (GETPOST("account") || GETPOST("ref")) { print '
'; print ''; print ''; - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { + if (getDolGlobalInt('MULTICOMPANY_INVOICE_SHARING_ENABLED')) { print ''; } print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index ab4b24e3889..95d5ffa0e9e 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -311,7 +311,7 @@ $form = new Form($db); if (!empty($conf->accounting->enabled)) { $formaccounting = new FormAccounting($db); } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -481,7 +481,7 @@ if ($action == 'create') { print ''; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); // Associated project @@ -553,7 +553,7 @@ if ($id) { $morehtmlref = '
'; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->banque->modifier) { diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index ad199caaf5a..b7cb8ee6bbf 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -97,7 +97,7 @@ if ($object->id) { $morehtmlref = '
'; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= $langs->trans('Project').' : '; if ($user->rights->banque->modifier && 0) { diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index e50dc10ff7f..b46ab36ddf6 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -57,7 +57,7 @@ print dol_get_fiche_head($head, 'info', $langs->trans("VariousPayment"), -1, $ob $morehtmlref = '
'; // Project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= $langs->trans('Project').' : '; if ($user->rights->banque->modifier && 0) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index bbec4f23fc6..0091dc39512 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -40,7 +40,6 @@ $socid = GETPOST("socid", "int"); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', '', '', ''); $optioncss = GETPOST('optioncss', 'alpha'); @@ -162,7 +161,7 @@ $arrayfields = array( 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), 'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130), 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), - 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), + 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->project->enabled)), 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)), 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)), @@ -173,6 +172,11 @@ $arrayfields = array( $arrayfields = dol_sort_array($arrayfields, 'position'); +$object = new PaymentVarious($db); + +$result = restrictedArea($user, 'banque', '', '', ''); + + /* * Actions */ @@ -271,19 +275,19 @@ if ($search_all) { $sql .= $db->order($sortfield, $sortorder); $totalnboflines = 0; -$result = $db->query($sql); -if ($result) { - $totalnboflines = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $totalnboflines = $db->num_rows($resql); } $sql .= $db->plimit($limit + 1, $offset); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); exit; @@ -535,13 +539,13 @@ if ($result) { $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); print ''; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $variousstatic->id = $obj->rowid; $variousstatic->ref = $obj->rowid; @@ -652,7 +656,7 @@ if ($result) { if ($arrayfields['account']['checked']) { $accountingaccount->fetch('', $obj->accountancy_code, 1); - print '
'; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -660,7 +664,7 @@ if ($result) { // Accounting subledger account if ($arrayfields['subledger']['checked']) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -704,7 +708,7 @@ if ($result) { $totalarray['nbfield']++; } - print ""; + print ''."\n"; $i++; } @@ -712,11 +716,27 @@ if ($result) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - print "
'.$langs->trans("Categories").''; print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1); print "
'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''.$object->ics.'
'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').''.$object->ics_transfer.'
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1082,12 +1083,12 @@ if ($action == 'create') { print '
'.$langs->trans($bickey).'
'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'
'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'
 
'.$langs->trans("Account").''; - if (!$objp->rappro && !$bankline->getVentilExportCompta()) { - print img_picto('', 'bank_account', 'class="paddingright"'); - print $form->select_comptes($acct->id, 'accountid', 0, '', 0, '', 0, '', 1); - } else { + // $objp->fk_account may be not > 0 if data was lost by an old bug. In such a case, we let a chance to user to fix it. + if (($objp->rappro || $bankline->getVentilExportCompta()) && $objp->fk_account > 0) { print $acct->getNomUrl(1, 'transactions', 'reflabel'); + } else { + print img_picto('', 'bank_account', 'class="paddingright"'); + print $form->select_comptes($acct->id, 'accountid', 0, '', ($acct->id > 0 ? $acct->id : 1), '', 0, '', 1); } print '
'.$objecttmp->getNomUrl(1).''.$objecttmp->getNomUrl(1).''; + print ''; print $objecttmp->type_lib[$objecttmp->type]; print ''; + print ''; if (!empty($conf->accounting->enabled)) { if (empty($objecttmp->fk_accountancy_journal)) { print img_warning($langs->trans("Mandatory")); @@ -606,7 +606,7 @@ foreach ($accounts as $key => $type) { // Currency if (!empty($arrayfields['b.currency_code']['checked'])) { - print ''; + print ''; print $objecttmp->currency_code; print ''; - $conciliate = $objecttmp->canBeConciliated(); + + $labeltoshow = ''; + if ($conciliate == -2) { + $labeltoshow = $langs->trans("CashAccount"); + } elseif ($conciliate == -3) { + $labeltoshow = $langs->trans("Closed"); + } elseif (empty($objecttmp->rappro)) { + $labeltoshow = $langs->trans("ConciliationDisabled"); + } + + print ''; if ($conciliate == -2) { print ''.$langs->trans("CashAccount").''; } elseif ($conciliate == -3) { @@ -630,7 +639,7 @@ foreach ($accounts as $key => $type) { if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } else { - print ''; + print ''; print ''; print $result->nbtodo; print ''; @@ -663,7 +672,7 @@ foreach ($accounts as $key => $type) { print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['b.datec']['checked'])) { - print ''; + print ''; print dol_print_date($objecttmp->date_creation, 'dayhour'); print ''; + print ''; print dol_print_date($objecttmp->date_update, 'dayhour'); print '
'.$langs->trans("DateDue").''.$langs->trans("Description").''.$langs->trans("Entity").''.$langs->trans("ThirdParty").'
'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.length_accounta($obj->subledger_account).''.length_accounta($obj->subledger_account).'
"; - print ''; - print ''; + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; + print '
'."\n"; + + print ''."\n"; } else { dol_print_error($db); } diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 149710c975b..2b6b027d7ce 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -647,7 +647,7 @@ if (empty($action) || $action == "view" || $action == "close") { print ''; print '
'; - print '
>'; + print '
'; print '
'; print ''; @@ -659,11 +659,11 @@ if (empty($action) || $action == "view" || $action == "close") { print ''; print '"; foreach ($arrayofpaymentmode as $key => $val) { print '"; } diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 63dae3a3a1c..d7744f777fe 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -439,13 +439,6 @@ class CashControl extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 78f9eae72a0..c16b6523d1f 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -153,7 +153,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $sql = "SELECT c.id, c.libelle as label,"; $sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pct.code as payment_code,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; @@ -185,7 +185,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $i = 0; $total = 0; $totalnb = 0; - $totalpaye = 0; + $totalpaid = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -239,15 +239,15 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { } // Paid print ''; print ''; $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; + $totalpaid = $totalpaid + $obj->totalpaid; $i++; } print ''; @@ -258,7 +258,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { if (!empty($conf->banque->enabled)) { print ''; } - print '"; + print '"; print ""; } else { dol_print_error($db); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 33b453cd0b4..59c2b373d1a 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -422,7 +422,7 @@ if ($action == 'create') { print ''; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load('projects'); print ''; print ''; print ''; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); // Associated project @@ -454,7 +454,7 @@ if ($id > 0) { if ($result > 0) { $head = tax_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); // Clone confirmation if ($action === 'clone') { @@ -539,7 +539,7 @@ if ($id > 0) { } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->tax->charges->creer) { @@ -551,11 +551,11 @@ if ($id > 0) { $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'fk_project', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'fk_project', 0, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, 0, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (!empty($object->fk_project)) { @@ -576,7 +576,7 @@ if ($id > 0) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -690,7 +690,7 @@ if ($id > 0) { //print $sql; $resql = $db->query($sql); if ($resql) { - $totalpaye = 0; + $totalpaid = 0; $num = $db->num_rows($resql); $i = 0; @@ -748,7 +748,7 @@ if ($id > 0) { } print '\n"; print ""; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { @@ -757,10 +757,10 @@ if ($id > 0) { print ''; } - print '\n"; + print '\n"; print '\n"; - $resteapayer = $object->amount - $totalpaye; + $resteapayer = $object->amount - $totalpaid; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; print '"; @@ -820,7 +820,7 @@ if ($id > 0) { } // Delete - if ($user->rights->tax->charges->supprimer && empty($totalpaye)) { + if ($user->rights->tax->charges->supprimer && empty($totalpaid)) { print ''; } else { print ''; @@ -863,7 +863,7 @@ if ($id > 0) { /* $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 6996c689922..3b9019868ec 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -113,6 +113,12 @@ class ChargeSociales extends CommonObject */ public $fk_user; + /** + * @var double total + */ + public $total; + + public $totalpaid; const STATUS_UNPAID = 0; const STATUS_PAID = 1; @@ -123,7 +129,7 @@ class ChargeSociales extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 9a4b50e3474..1b83915714d 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -100,12 +100,28 @@ class PaymentSocialContribution extends CommonObject */ public $fk_user_modif; + /** + * @var int ID + */ + public $chid; + + /** + * @var integer|string datepaye + */ + public $datepaye; + + /** + * @var integer|string paiementtype + */ + public $paiementtype; + + /** * Constructor * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 6918b2c84ee..2b0d17337a5 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -101,7 +101,7 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) { */ $form = new Form($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -121,7 +121,7 @@ if ($object->id) { $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' : '; if (!empty($object->fk_project)) { @@ -139,7 +139,9 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $alreadypayed; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + $morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 4c49a3008c6..0976a76c26d 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -25,7 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -68,7 +68,7 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) { $form = new Form($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -81,6 +81,8 @@ $object->info($id); $head = tax_prepare_head($object); +$alreadypayed = $object->getSommePaiement(); + print dol_get_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, $object->picto); $morehtmlref = '
'; @@ -88,7 +90,7 @@ $morehtmlref = '
'; $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); // Project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' : '; if (!empty($object->fk_project)) { @@ -106,8 +108,9 @@ $morehtmlref .= '
'; $linkback = ''.$langs->trans("BackToList").''; -$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $alreadypayed; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 8d63e52256e..93c8dea0a3e 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -112,7 +112,7 @@ $arrayfields = array( 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30), 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40), 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50), - 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->projet->enabled))), + 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->project->enabled))), 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70), 'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"), 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100), @@ -191,7 +191,7 @@ $formother = new FormOther($db); $bankstatic = new Account($db); $formsocialcontrib = new FormSocialContrib($db); $chargesociale_static = new ChargeSociales($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $projectstatic = new Project($db); } @@ -199,7 +199,7 @@ llxHeader('', $langs->trans("SocialContributions")); $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,"; $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,"; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; } $sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,"; @@ -209,7 +209,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; @@ -223,7 +223,7 @@ if ($search_ref) { if ($search_label) { $sql .= natural_search("cs.libelle", $search_label); } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { if ($search_project_ref != '') { $sql .= natural_search("p.ref", $search_project_ref); } @@ -259,7 +259,7 @@ if ($search_typeid > 0) { $sql .= " AND cs.fk_type = ".((int) $search_typeid); } $sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, cs.fk_account, c.libelle, c.accountancy_code, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, pay.code, u.lastname"; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $sql .= ", p.rowid, p.ref, p.title"; } $sql .= $db->order($sortfield, $sortorder); @@ -560,7 +560,7 @@ while ($i < min($num, $limit)) { $chargesociale_static->label = $obj->label; $chargesociale_static->type_label = $obj->type_label; - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; @@ -713,16 +713,35 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } - print '
'; + print ''."\n"; + $i++; } // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; -print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); + print ''.price($object->opening, 0, $langs, 1, -1, -1, $conf->currency).''; print "
'.$langs->trans($val).''; - print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print ''.price($object->$key, 0, $langs, 1, -1, -1, $conf->currency).''; print "
'; - if ($obj->totalpaye) { - print price($obj->totalpaye); + if ($obj->totalpaid) { + print price($obj->totalpaid); } print '
'.$langs->trans("Total").''.price($totalpaye)."'.price($totalpaid)."
'; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index e05750918da..c09943540bc 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -121,7 +121,7 @@ class Deplacement extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 9f92cecc4a7..2aa03441e9b 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -158,7 +158,7 @@ if ($resql) { print ''; } print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5); print ''; print ''; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index b3ca5f5f233..42fb64738e1 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -83,7 +83,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 7d2d2b1df97..1c834134f6d 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 05aa47737be..7b7f62ed94c 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 6ebdfae6277..900aab1e10b 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6300e387067..18a935cedb4 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -34,7 +34,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } @@ -201,12 +201,12 @@ if (empty($reshook)) { } if (!$error) { - $object->titre = GETPOST('title', 'nohtml'); // deprecated - $object->title = GETPOST('title', 'nohtml'); + $object->titre = GETPOST('title', 'alphanohtml'); // deprecated + $object->title = GETPOST('title', 'alphanohtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->model_pdf = GETPOST('modelpdf', 'alpha'); - $object->usenewprice = GETPOST('usenewprice', 'alpha'); + $object->model_pdf = GETPOST('modelpdf', 'alphanohtml'); + $object->usenewprice = GETPOST('usenewprice', 'alphanohtml'); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); @@ -924,7 +924,7 @@ llxHeader('', $langs->trans("RepeatableInvoices"), $help_url); $form = new Form($db); $formother = new FormOther($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } $companystatic = new Societe($db); @@ -954,7 +954,7 @@ if ($action == 'create') { print dol_get_fiche_head(null, '', '', 0); $rowspan = 4; - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $rowspan++; } if ($object->fk_account > 0) { @@ -1047,7 +1047,7 @@ if ($action == 'create') { } // Project - if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { + if (!empty($conf->project->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; $langs->load('projects'); print '
'.$langs->trans('Project').''; @@ -1203,7 +1203,7 @@ if ($action == 'create') { // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->facture->creer) { @@ -1695,7 +1695,20 @@ if ($action == 'create') { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print ''; + print ''; + print '
'; + + $MAXEVENT = 10; + + //$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + + print '
'; + print ''; } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e3fac863c77..ca07f30f838 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -54,7 +54,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (!empty($conf->commande->enabled)) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -142,9 +142,9 @@ if (!empty($conf->global->INVOICE_DISALLOW_REOPEN)) { $usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); -$usercancreatemargin = $user->rights->margins->creer; -$usercanreadallmargin = $user->rights->margins->liretous; -$usercancreatewithdrarequest = $user->rights->prelevement->bons->creer; +$usercancreatemargin = (!empty($user->rights->margins->creer) ? $user->rights->margins->creer : 0); +$usercanreadallmargin = (!empty($user->rights->margins->liretous) ? $user->rights->margins->liretous : 0); +$usercancreatewithdrarequest = (!empty($user->rights->prelevement->bons->creer) ? $user->rights->prelevement->bons->creer : 0); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php @@ -305,7 +305,7 @@ if (empty($reshook)) { $object->fetch($id); if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $object->willBeLastOfSameType(); + $last_of_type = $object->willBeLastOfSameType(true); if (empty($object->date_validation) && !$last_of_type[0]) { setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); $action = ''; @@ -725,14 +725,14 @@ if (empty($reshook)) { while ($i < $num) { $objp = $db->fetch_object($result); - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { dol_print_error($db, ''); } - $resteapayer = $object->total_ttc - $totalpaye; + $resteapayer = $object->total_ttc - $totalpaid; // We check that invlice lines are transferred into accountancy $ventilExportCompta = $object->getVentilExportCompta(); @@ -1255,10 +1255,10 @@ if (empty($reshook)) { if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { if ($facture_source->fetch($object->fk_facture_source) > 0) { - $totalpaye = $facture_source->getSommePaiement(); + $totalpaid = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); $totaldeposits = $facture_source->getSumDepositsUsed(); - $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); + $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits); $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC'); } @@ -2874,7 +2874,7 @@ $formmargin = new FormMargin($db); $soc = new Societe($db); $paymentstatic = new Paiement($db); $bankaccountstatic = new Account($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -3290,7 +3290,7 @@ if ($action == 'create') { $typedeposit = GETPOST('typedeposit', 'aZ09'); $valuedeposit = GETPOST('valuedeposit', 'int'); if (empty($typedeposit) && ! empty($objectsrc->deposit_percent)) { - $origin_payment_conditions_deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id); + $origin_payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id); if (! empty($origin_payment_conditions_deposit_percent)) { $typedeposit = 'variable'; } @@ -3658,7 +3658,7 @@ if ($action == 'create') { } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load('projects'); print '
'.$langs->trans('Project').''; print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); @@ -3899,24 +3899,24 @@ if ($action == 'create') { } $selleruserevenustamp = $mysoc->useRevenueStamp(); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." + //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." // selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + // $resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency if (!empty($conf->multicurrency->enabled)) { - $multicurrency_totalpaye = $object->getSommePaiement(1); + $multicurrency_totalpaid = $object->getSommePaiement(1); $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); - $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); + $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); // Code to fix case of corrupted data if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); @@ -4284,7 +4284,7 @@ if ($action == 'create') { $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($usercancreate) { @@ -4317,7 +4317,7 @@ if ($action == 'create') { } $morehtmlref .= ''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', ''); @@ -4325,7 +4325,7 @@ if ($action == 'create') { print '
'; print '
'; - print ''; + print '
'; // Type print ''; if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { - // Date invoice + // Date invoice point of tax print '
'.$langs->trans('Type').''; @@ -4338,17 +4338,17 @@ if ($action == 'create') { if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; + print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).''; } if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; + print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; } $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { - print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + print ' '.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; foreach ($facidavoir as $id) { if ($i == 0) { @@ -4360,12 +4360,12 @@ if ($action == 'create') { $facavoir->fetch($id); print $facavoir->getNomUrl(1); } - print ')'; + print ''; } if ($objectidnext > 0) { $facthatreplace = new Facture($db); $facthatreplace->fetch($objectidnext); - print ' ('.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).')'; + print ' '.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).''; } if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { @@ -4425,7 +4425,7 @@ if ($action == 'create') { print '
'; print ''; - print ''; + print ''; } // Revenue stamp @@ -4803,7 +4803,7 @@ if ($action == 'create') { $nbrows = 8; $nbcols = 3; - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $nbrows++; } if (!empty($conf->banque->enabled)) { @@ -4926,7 +4926,7 @@ if ($action == 'create') { $total_next_ht = $total_next_ttc = 0; foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaye = $next_invoice->getSommePaiement(); + $totalpaid = $next_invoice->getSommePaiement(); $total_next_ht += $next_invoice->total_ht; $total_next_ttc += $next_invoice->total_ttc; @@ -4939,7 +4939,7 @@ if ($action == 'create') { } print ''; print ''; - print ''; + print ''; print ''; } @@ -5008,7 +5008,7 @@ if ($action == 'create') { $paymentstatic->datepaye = $db->jdate($objp->dp); $paymentstatic->ref = $objp->ref; $paymentstatic->num_payment = $objp->num_payment; - $paymentstatic->payment_code = $objp->payment_code; + $paymentstatic->paiementcode = $objp->payment_code; print ''; + print ''; $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; @@ -5125,7 +5125,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); print ''; - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5135,7 +5135,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); print ''; - print ''; + print ''; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5145,7 +5145,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); print ''; - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5159,7 +5159,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); print ''; - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5220,7 +5220,7 @@ if ($action == 'create') { // Total already paid back print ''; + print ''; // Billed print ''; @@ -5426,7 +5426,7 @@ if ($action == 'create') { // Create contract if (!empty($conf->global->CONTRACT_CREATE_FROM_INVOICE)) { - if ($conf->contrat->enabled && $object->statut == Facture::STATUS_VALIDATED) { + if (!empty($conf->contrat->enabled) && $object->statut == Facture::STATUS_VALIDATED) { $langs->load("contracts"); if ($usercancreatecontract) { @@ -5498,8 +5498,8 @@ if ($action == 'create') { } } - $sumofpayment = $totalpaye; - $sumofpaymentall = $totalpaye + $totalcreditnotes + $totaldeposits; + $sumofpayment = $totalpaid; + $sumofpaymentall = $totalpaid + $totalcreditnotes + $totaldeposits; // Reverse back money or convert to reduction if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) { @@ -5551,7 +5551,7 @@ if ($action == 'create') { // Classify 'closed not completely paid' (possible if validated and not yet filed paid) if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID) || $resteapayer != $object->total_ttc) && $usercanissuepayment) { - if ($totalpaye > 0 || $totalcreditnotes > 0) { + if ($totalpaid > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; } else { @@ -5575,7 +5575,7 @@ if ($action == 'create') { // For situation invoice with excess received if ($object->statut > Facture::STATUS_DRAFT && $object->type == Facture::TYPE_SITUATION - && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 + && ($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits) > 0 && $usercancreate && !$objectidnext && $object->is_last_in_cycle() diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3623a36cbb9..a864168d161 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -148,7 +148,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->invoice->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->invoice->contacts_ids = $tmparray; + } } $this->invoice->fetchObjectLinked(); @@ -267,8 +270,10 @@ class Invoices extends DolibarrApi $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); // Add external contacts ids - $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); - + $tmparray = $invoice_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $invoice_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($invoice_static); } $i++; @@ -423,8 +428,8 @@ class Invoices extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->invoice->updateline( $lineid, @@ -451,7 +456,8 @@ class Invoices extends DolibarrApi $request_data->fk_unit, $request_data->multicurrency_subprice, 0, - $request_data->ref_ext + $request_data->ref_ext, + $request_data->rang ); if ($updateRes > 0) { @@ -712,8 +718,8 @@ class Invoices extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); // Reset fk_parent_line for no child products and special product if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) { @@ -1419,10 +1425,10 @@ class Invoices extends DolibarrApi } // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); + $totalpaid = $this->invoice->getSommePaiement(); $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); $this->db->begin(); @@ -1561,10 +1567,10 @@ class Invoices extends DolibarrApi } // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement($is_multicurrency); + $totalpaid = $this->invoice->getSommePaiement($is_multicurrency); $totalcreditnotes = $this->invoice->getSumCreditNotesUsed($is_multicurrency); $totaldeposits = $this->invoice->getSumDepositsUsed($is_multicurrency); - $remainstopay = $amount = price2num($total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $remainstopay = $amount = price2num($total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if (!$is_multicurrency && $amountarray["amount"] != 'remain') { $amount = price2num($amountarray["amount"], 'MT'); @@ -1767,7 +1773,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->template_invoice->contacts_ids = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->template_invoice->contacts_ids = $tmparray; + } } $this->template_invoice->fetchObjectLinked(); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 7058364d1f1..f15f65954cf 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -169,7 +169,7 @@ class FactureRec extends CommonInvoice 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30), //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40), @@ -181,7 +181,7 @@ class FactureRec extends CommonInvoice 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'Total', 'enabled'=>1, 'visible'=>-1, 'position'=>70, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>75, 'isameasure'=>1), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>85), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Fk cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>90), 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'Fk mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>95), 'date_lim_reglement' =>array('type'=>'date', 'label'=>'Date lim reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>100), @@ -199,7 +199,7 @@ class FactureRec extends CommonInvoice 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>160, 'isameasure'=>1), 'auto_validate' =>array('type'=>'integer', 'label'=>'Auto validate', 'enabled'=>1, 'visible'=>-1, 'position'=>165), 'generate_pdf' =>array('type'=>'integer', 'label'=>'Generate pdf', 'enabled'=>1, 'visible'=>-1, 'position'=>170), - 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>175), 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>180), 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency tx', 'enabled'=>1, 'visible'=>-1, 'position'=>190, 'isameasure'=>1), @@ -222,7 +222,7 @@ class FactureRec extends CommonInvoice * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -270,6 +270,7 @@ class FactureRec extends CommonInvoice if ($result > 0) { // On positionne en mode brouillon la facture $this->brouillon = 1; + $this->fk_soc = $facsrc->socid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec ("; $sql .= "titre"; @@ -301,7 +302,7 @@ class FactureRec extends CommonInvoice $sql .= ", suspended"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; - $sql .= ", ".((int) $facsrc->socid); + $sql .= ", ".((int) $this->fk_soc); $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0'); @@ -1256,9 +1257,10 @@ class FactureRec extends CommonInvoice * * @param int $restrictioninvoiceid 0=All qualified template invoices found. > 0 = restrict action on invoice ID * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. + * @param int $notrigger Disable the trigger * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) + public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0, $notrigger = 0) { global $conf, $langs, $db, $user, $hookmanager; @@ -1331,6 +1333,11 @@ class FactureRec extends CommonInvoice $facture->status = self::STATUS_DRAFT; $facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; + if (!empty($facturerec->fk_multicurrency)) { + $facture->fk_multicurrency = $facturerec->fk_multicurrency; + $facture->multicurrency_code = $facturerec->multicurrency_code; + $facture->multicurrency_tx = $facturerec->multicurrency_tx; + } $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { @@ -1338,6 +1345,8 @@ class FactureRec extends CommonInvoice $this->error = $facture->error; $error++; } + + if (!$error && ($facturerec->auto_validate || $forcevalidation)) { $result = $facture->validate($user); if ($result <= 0) { @@ -1356,6 +1365,16 @@ class FactureRec extends CommonInvoice $error++; } } + if (!$error && !$notrigger) { + // Call trigger + $result = $facturerec->call_trigger('BILLREC_CREATEBILL', $user); + if ($result < 0) { + $this->errors = $facturerec->errors; + $this->error = $facturerec->error; + $error++; + } + // End call triggers + } } else { $error++; $this->error = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; @@ -1788,10 +1807,13 @@ class FactureRec extends CommonInvoice * * @param int $frequency value of frequency * @param string $unit unit of frequency (d, m, y) + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setFrequencyAndUnit($frequency, $unit) + public function setFrequencyAndUnit($frequency, $unit, $notrigger = 0) { + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1815,6 +1837,16 @@ class FactureRec extends CommonInvoice if (!empty($unit)) { $this->unit_frequency = $unit; } + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1827,10 +1859,14 @@ class FactureRec extends CommonInvoice * * @param datetime $date date of execution * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setNextDate($date, $increment_nb_gen_done = 0) + public function setNextDate($date, $increment_nb_gen_done = 0, $notrigger = 0) { + + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1848,6 +1884,15 @@ class FactureRec extends CommonInvoice if ($increment_nb_gen_done > 0) { $this->nb_gen_done++; } + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } return 1; } else { dol_print_error($this->db); @@ -1859,10 +1904,14 @@ class FactureRec extends CommonInvoice * Update the maximum period * * @param int $nb number of maximum period + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setMaxPeriod($nb) + public function setMaxPeriod($nb, $notrigger = 0) { + + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1879,6 +1928,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) { $this->nb_gen_max = $nb; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1890,10 +1949,13 @@ class FactureRec extends CommonInvoice * Update the auto validate flag of invoice * * @param int $validate 0 to create in draft, 1 to create and validate invoice + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setAutoValidate($validate) + public function setAutoValidate($validate, $notrigger = 0) { + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1906,6 +1968,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) { $this->auto_validate = $validate; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1917,10 +1989,13 @@ class FactureRec extends CommonInvoice * Update the auto generate documents * * @param int $validate 0 no document, 1 to generate document + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setGeneratePdf($validate) + public function setGeneratePdf($validate, $notrigger = 0) { + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1933,6 +2008,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); if ($this->db->query($sql)) { $this->generate_pdf = $validate; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1944,10 +2029,12 @@ class FactureRec extends CommonInvoice * Update the model for documents * * @param string $model model of document generator + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setModelPdf($model) + public function setModelPdf($model, $notrigger = 0) { + global $user; if (!$this->table_element) { dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1960,6 +2047,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); if ($this->db->query($sql)) { $this->model_pdf = $model; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0804f55b1ee..5993bd39a7c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -428,7 +428,7 @@ class Facture extends CommonInvoice * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -560,7 +560,6 @@ class Facture extends CommonInvoice $this->array_options = $_facrec->array_options; - //if (! $this->remise) $this->remise = 0; if (!$this->mode_reglement_id) { $this->mode_reglement_id = 0; } @@ -1501,7 +1500,7 @@ class Facture extends CommonInvoice return null; } - $payment_conditions_deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $origin->cond_reglement_id); + $payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $origin->cond_reglement_id); if (empty($payment_conditions_deposit_percent)) { $origin->error = 'ErrorPaymentConditionsNotEligibleToDepositCreation'; @@ -1652,13 +1651,13 @@ class Facture extends CommonInvoice 0, // date_start 0, // date_end 0, - $lines[$i]->info_bits, // info_bits + 0, // info_bits 0, 'HT', 0, 0, // product_type 1, - $lines[$i]->special_code, + 0, // special_code $deposit->origin, 0, 0, @@ -2194,9 +2193,11 @@ class Facture extends CommonInvoice // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$i] = $line; @@ -3009,7 +3010,7 @@ class Facture extends CommonInvoice return -1; } if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $this->willBeLastOfSameType(); + $last_of_type = $this->willBeLastOfSameType(true); if (!$last_of_type[0]) { $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); return -1; @@ -3840,9 +3841,10 @@ class Facture extends CommonInvoice * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger * @param string $ref_ext External reference of the line + * @param integer $rang rank of line * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $user; // Deprecation warning @@ -3970,6 +3972,7 @@ class Facture extends CommonInvoice $line->oldline = $staticline; $this->line = $line; $this->line->context = $this->context; + $this->line->rang = $rang; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { @@ -5022,7 +5025,7 @@ class Facture extends CommonInvoice $sql .= " WHERE f.entity IN (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { - if ($resql->num_rows > 0) { + if ($this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $ref = $res['max(situation_cycle_ref)']; $ref++; @@ -5067,7 +5070,7 @@ class Facture extends CommonInvoice $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); $res = array(); - if ($resql && $resql->num_rows > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { while ($row = $this->db->fetch_object($resql)) { $id = $row->rowid; $situation = new Facture($this->db); @@ -5145,7 +5148,7 @@ class Facture extends CommonInvoice $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $last = $res['max(situation_counter)']; return ($last == $this->situation_counter); @@ -5211,13 +5214,13 @@ class Facture extends CommonInvoice $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) { - $totalpaye = $this->getSommePaiement(); - $totalpaye = floatval($totalpaye); + $totalpaid = $this->getSommePaiement(); + $totalpaid = floatval($totalpaid); $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); - if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) { - if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { + if ($totalpaid >= 0 && $RetainedWarrantyAmount >= 0) { + if (($totalpaid < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; - } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { + } elseif ($totalpaid < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; } else { $hasDelay = 0; @@ -5412,7 +5415,7 @@ class Facture extends CommonInvoice $langs->load("bills"); - if (empty($conf->facture->enabled)) { // Should not happen. If module disabled, cron job should not be visible. + if (!isModEnabled('facture')) { // Should not happen. If module disabled, cron job should not be visible. $this->output .= $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Facture")); return 0; } @@ -5501,6 +5504,7 @@ class Facture extends CommonInvoice $sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1); // Recipient + $to = ''; $res = $tmpinvoice->fetch_thirdparty(); $recipient = $tmpinvoice->thirdparty; if ($res > 0) { @@ -5522,7 +5526,7 @@ class Facture extends CommonInvoice $error++; } - if (!$error) { + if (!$error && $to) { // Errors Recipient $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; @@ -5565,9 +5569,10 @@ class Facture extends CommonInvoice /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. + * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. * @return boolean */ - public function willBeLastOfSameType() + public function willBeLastOfSameType($allow_validated_drafts = false) { // get date of last validated invoices of same type $sql = "SELECT datef"; @@ -5584,7 +5589,12 @@ class Facture extends CommonInvoice $last_date = $this->db->jdate($obj->datef); $invoice_date = $this->date; - return [$invoice_date >= $last_date, $last_date]; + $is_last_of_same_type = $invoice_date >= $last_date; + if ($allow_validated_drafts) { + $is_last_of_same_type = $is_last_of_same_type || (!strpos($this->ref, 'PROV') && $this->status == self::STATUS_DRAFT); + } + + return [$is_last_of_same_type, $last_date]; } else { // element is first of type to be validated return [true]; @@ -6278,7 +6288,7 @@ class FactureLigne extends CommonInvoiceLine $sql = "SELECT situation_percent FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->fk_prev_id); $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $returnPercent = floatval($res['situation_percent']); diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index a54cd1a6668..522fe9aa2e2 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -57,7 +57,7 @@ class FactureStats extends Stats * @param int $typentid Id typent of thirdpary for filter * @param int $categid Id category of thirdpary for filter */ - public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $categid = 0) + public function __construct(DoliDB $db, $socid, $mode, $userid = 0, $typentid = 0, $categid = 0) { global $user, $conf; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index f94ad573a81..3ad533b6d3b 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -68,7 +68,7 @@ class PaymentTerm // extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -172,9 +172,10 @@ class PaymentTerm // extends CommonObject * Load object in memory from database * * @param int $id Id object + * @param string $code Code object * @return int <0 if KO, >0 if OK */ - public function fetch($id) + public function fetch($id, $code = '') { global $langs; $sql = "SELECT"; @@ -192,7 +193,12 @@ class PaymentTerm // extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; - $sql .= " WHERE t.rowid = ".((int) $id); + if ($id) { + $sql .= " WHERE t.rowid = ".((int) $id); + } + if ($code) { + $sql .= " WHERE t.code='".$this->db->escape($code)."' AND t.entity IN (".getEntity('payment_term').")"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 43897172779..1b75d43753e 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -52,7 +52,7 @@ if ($user->socid) { $object = new Facture($db); // Load object if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } $result = restrictedArea($user, 'facture', $object->id); @@ -122,7 +122,7 @@ if ($id > 0 || !empty($ref)) { $head = facture_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); print dol_get_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill'); @@ -137,7 +137,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->facture->creer) { @@ -171,13 +171,13 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= ''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); print dol_get_fiche_end(); - print '
'; + //print '
'; // Contacts lines (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 6eb05a16922..1685da08a2e 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -117,7 +117,7 @@ if ($id > 0 || !empty($ref)) { $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -138,7 +138,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->facture->creer) { @@ -172,7 +172,7 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= ''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 60efaf36e3d..8b198e5f991 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -47,7 +47,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } // Security check @@ -84,7 +84,7 @@ $object->info($object->id); $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); -$totalpaye = $object->getSommePaiement(); +$totalpaid = $object->getSommePaiement(); // Invoice content @@ -97,7 +97,7 @@ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_cl // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->facture->creer) { @@ -131,7 +131,7 @@ if (!empty($conf->projet->enabled)) { } $morehtmlref .= ''; -$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); @@ -140,7 +140,7 @@ print '
'; print '
'; -print '
'; print $langs->trans('DatePointOfTax'); @@ -4740,7 +4740,7 @@ if ($action == 'create') { } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2 print '
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaye).''.$next_invoice->getLibStatut(3, $totalpaid).'
'; print $paymentstatic->getNomUrl(1); @@ -5072,7 +5072,7 @@ if ($action == 'create') { } else { print $langs->trans('AlreadyPaid'); } - print ''.price($totalpaye).' 
'.price($totalpaid).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; print ''.$langs->trans('AlreadyPaidBack').''; - print ''.price($sign * $totalpaye).' 
'.price($sign * $totalpaid).' 
'.$langs->trans("Billed").''.price($sign * $object->total_ttc).' 
'; if (!$i) { @@ -865,7 +865,7 @@ if ($resql) { } } if (!empty($arrayfields['f.tms']['checked'])) { - print ''; if (!$i) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 2ef50801717..cac6229f86b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -141,7 +141,6 @@ $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); - $option = GETPOST('search_option'); if ($option == 'late') { $search_status = '1'; @@ -216,8 +215,8 @@ $arrayfields = array( 'f.date_valid'=>array('label'=>"DateValidation", 'checked'=>0, 'position'=>22), 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25), 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>41), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>40), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>55), @@ -245,7 +244,7 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>292), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>295), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>296), // Not enabled by default because slow - 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), + 'total_pa' => array('label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), @@ -472,10 +471,10 @@ if ($action == 'makepayment_confirm' && !empty($user->rights->facture->paiement) $objecttmp = new Facture($db); $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $totalpaye = $objecttmp->getSommePaiement(); + $totalpaid = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); - $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if ($objecttmp->statut == Facture::STATUS_DRAFT) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors'); @@ -1112,7 +1111,7 @@ if ($resql) { if (!empty($user->rights->facture->paiement)) { $arrayofmassactions['makepayment'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakePaymentAndClassifyPayed"); } - if ($conf->prelevement->enabled && !empty($user->rights->prelevement->bons->creer)) { + if (!empty($conf->prelevement->enabled) && !empty($user->rights->prelevement->bons->creer)) { $langs->load("withdrawals"); $arrayofmassactions['withdrawrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeWithdrawRequest"); } @@ -2415,16 +2414,27 @@ if ($resql) { include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; } + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; + } + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print "
'; +print '
'; dol_print_object_info($object); print '
'; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index af1ab95c2b5..1f516c31795 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -257,7 +257,7 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur $form = new Form($db); $formother = new FormOther($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } $companystatic = new Societe($db); @@ -857,7 +857,7 @@ if ($resql) { } } if (!empty($arrayfields['f.datec']['checked'])) { - print '
'; + print ''; print dol_print_date($db->jdate($objp->datec), 'dayhour'); print ''; + print ''; print dol_print_date($db->jdate($objp->tms), 'dayhour'); print '
'.$langs->trans("NoRecordFound").'
\n"; - print ''; + print '
'."\n"; + print '
'."\n"; - print "\n"; + print ''."\n"; // Show the file area only when this page is not opend from the Extended POS if ($contextpage != 'poslist') { diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 6f699774d32..5b30d39da12 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -44,7 +44,7 @@ $action = GETPOST('action', 'aZ09'); $object = new Facture($db); // Load object if ($id > 0 || !empty($ref)) { - $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php @@ -99,7 +99,7 @@ if ($id > 0 || !empty($ref)) { $head = facture_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'); @@ -114,7 +114,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->facture->creer) { @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= ''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 316254b0398..8bd953f98b5 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -236,16 +236,16 @@ llxHeader('', $title, $helpurl); if ($object->id > 0) { $selleruserevenustamp = $mysoc->useRevenueStamp(); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if ($object->paye) { $resteapayer = 0; @@ -281,8 +281,8 @@ if ($object->id > 0) { } $author = new User($db); - if ($object->user_author) { - $author->fetch($object->user_author); + if ($object->fk_user_author) { + $author->fetch($object->fk_user_author); } if ($type == 'bank-transfer') { @@ -310,9 +310,9 @@ if ($object->id > 0) { $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); - if ($result_sql) { - $num = $db->num_rows($result_sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); $numopen = $num; } else { dol_print_error($db); @@ -349,12 +349,12 @@ if ($object->id > 0) { } } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) { + if ($usercancreate) { if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; $morehtmlref .= ' : '; } if ($action == 'classify') { @@ -384,7 +384,7 @@ if ($object->id > 0) { } $morehtmlref .= ''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $moreparam, 0, '', ''); @@ -395,12 +395,12 @@ if ($object->id > 0) { print ''; // Type - print ''; - // Discounts - print ''; - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // TODO Replace this by an include with same code to show already done payment visible in invoice card print ''; @@ -695,9 +697,9 @@ if ($object->id > 0) { $sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.ext_payment_id IS NULL"; - $result_sql = $db->query($sql); - if ($result_sql) { - $obj = $db->fetch_object($result_sql); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); if ($obj) { $pending = $obj->amount; } @@ -797,17 +799,17 @@ if ($object->id > 0) { $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); + $resql = $db->query($sql); $num = 0; - if ($result_sql) { + if ($resql) { $i = 0; $tmpuser = new User($db); $num = $db->num_rows($result); while ($i < $num) { - $obj = $db->fetch_object($result_sql); + $obj = $db->fetch_object($resql); $tmpuser->id = $obj->user_id; $tmpuser->login = $obj->login; @@ -840,7 +842,7 @@ if ($object->id > 0) { $i++; } - $db->free($result_sql); + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 6ee1a057664..cb0e38b7a34 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -102,7 +102,7 @@ if ($mode == 'customer') { $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($object_status).')'; } if (is_array($custcats) && !empty($custcats)) { - $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat OmdN (f.fk_soc = cat.fk_soc)'; + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; $stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')'; } } diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 207f806dc74..93b73d8ddd4 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -102,21 +102,26 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); print '
'; -//print getCustomerInvoicePieChart($socid); print getNumberInvoicesPieChart('customers'); print '
'; -print getNumberInvoicesPieChart('fourn'); -//print getPurchaseInvoicePieChart($socid); -print '
'; + +if (!empty($conf->fournisseur->enabled)) { + print getNumberInvoicesPieChart('fourn'); + print '
'; +} + print getCustomerInvoiceDraftTable($max, $socid); -print '
'; -print getDraftSupplierTable($max, $socid); + +if (!empty($conf->fournisseur->enabled)) { + print '
'; + print getDraftSupplierTable($max, $socid); +} print '
'; // Latest modified customer invoices -if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { +if (isModEnabled('facture') && !empty($user->rights->facture->lire)) { $langs->load("boxes"); $tmpinvoice = new Facture($db); @@ -577,7 +582,7 @@ if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) { /* * Customers orders to be billed */ -if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { +if (isModEnabled('facture') && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { $commandestatic = new Commande($db); $langs->load("orders"); diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 234073cdb38..28d095715c2 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -293,7 +293,7 @@ $mend = $tmp['mon']; $total = 0; $subtotalcoll = 0; -$subtotalpaye = 0; +$subtotalpaid = 0; $subtotal = 0; $i = 0; $mcursor = 0; @@ -536,7 +536,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print '
'; $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalpaid = $subtotalpaid + $x_paye_sum; $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; @@ -552,12 +552,12 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; $i = 0; $subtotalcoll = 0; - $subtotalpaye = 0; + $subtotalpaid = 0; $subtotal = 0; } } diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 2306e99899b..bd5c114e983 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -52,7 +52,7 @@ $hookmanager->initHooks(array('paymentcard', 'globalcard')); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$result = restrictedArea($user, $object->element, $object->id, 'paiement', ''); +$result = restrictedArea($user, $object->element, $object->id, 'paiement'); // Security check if ($user->socid) { diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 451a18ab05b..3fb82f05cb9 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -200,8 +200,9 @@ class RemiseCheque extends CommonObject } } + $lines = array(); + if ($this->id > 0 && $this->errno == 0) { - $lines = array(); $sql = "SELECT b.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.fk_type = 'CHQ'"; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index d12caf36bbe..1c3abfe87bd 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -172,7 +172,7 @@ if ($resql) { print ''; } print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5); print ''; print ''; print '';*/ @@ -291,7 +291,7 @@ if ($action == 'create') { print "\n"; $total += $objp->total; $total_ttc += $objp->total_ttc; - $totalrecu += $objp->am; + $totalrecu += $objp->amount; $i++; } if ($i > 1) { diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 28bc838c296..645fd36bc2a 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -194,7 +194,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print ''; print '';*/ @@ -290,7 +290,7 @@ if ($action == 'create') { print "\n"; $total += $objp->total; $total_ttc += $objp->total_ttc; - $totalrecu += $objp->am; + $totalrecu += $objp->amount; $i++; } if ($i > 1) { diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 6c14987e5ba..ee7cc064df6 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -159,11 +159,11 @@ if ($resql) { $thirdpartystatic->idprof5 = $obj->idprof5; $thirdpartystatic->idprof6 = $obj->idprof6; - print ''; - print ''; @@ -226,14 +226,14 @@ if ($result) { print ''; - print "\n"; print '\n"; - print '\n"; + print '\n"; print '\n"; print "\n"; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 469985679c9..129f083895c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -185,18 +185,18 @@ if ($id > 0 || $ref) { print ''; */ - if ($object->date_trans <> 0) { + if (!empty($object->date_trans)) { $muser = new User($db); $muser->fetch($object->user_trans); print ''; + print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; print ''; } - if ($object->date_credit <> 0) { + if (!empty($object->date_credit)) { print ''; @@ -290,7 +290,7 @@ if ($id > 0 || $ref) { print '
'; } - if (!empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action == 'setcredited') { + if (!empty($object->date_trans) && empty($object->date_credit) && $user->rights->prelevement->bons->credit && $action == 'setcredited') { $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited"); print ''; print ''; @@ -318,8 +318,7 @@ if ($id > 0 || $ref) { if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->send); else print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->send); } - - if (!empty($object->date_trans) && $object->date_credit == 0) { + if (!empty($object->date_trans) && empty($object->date_credit)) { if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->debit); else print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->credit); } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4f9eb4e456e..8cfdcf7e02b 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -78,6 +78,8 @@ class BonPrelevement extends CommonObject public $statut; // 0-Wait, 1-Trans, 2-Done public $labelStatus = array(); + public $factures = array(); + public $invoice_in_error = array(); public $thirdparty_in_error = array(); @@ -394,10 +396,10 @@ class BonPrelevement extends CommonObject $amounts[$fac->id] = $facs[$i][1]; $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; - $totalpaye = $fac->getSommePaiement(); + $totalpaid = $fac->getSommePaiement(); $totalcreditnotes = $fac->getSumCreditNotesUsed(); $totaldeposits = $fac->getSumDepositsUsed(); - $alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits; + $alreadypayed = $totalpaid + $totalcreditnotes + $totaldeposits; // @TODO Move this after creation of payment if (price2num($alreadypayed + $facs[$i][1], 'MT') == $fac->total_ttc) { @@ -913,6 +915,7 @@ class BonPrelevement extends CommonObject $this->db->begin(); $now = dol_now(); + $ref = ''; /* * Process order generation @@ -1066,8 +1069,8 @@ class BonPrelevement extends CommonObject // This also set the property $this->total with amount that is included into file $result = $this->generate($format, $executiondate, $type); if ($result < 0) { - /*var_dump($this->error); - var_dump($this->invoice_in_error); */ + //var_dump($this->error); + //var_dump($this->invoice_in_error); $error++; } } @@ -1243,13 +1246,6 @@ class BonPrelevement extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1492,7 +1488,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ''))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1608,7 +1604,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ''))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1858,16 +1854,16 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom), ''))).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1927,16 +1923,16 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom)))).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; @@ -2100,16 +2096,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ''))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2124,11 +2120,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS.'').$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS), '')).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), '')).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV @@ -2166,16 +2162,16 @@ class BonPrelevement extends CommonObject } $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ''))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ''), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2190,11 +2186,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS).''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS), '')).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), '')).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index fc640eccc1c..df45a5bdabd 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -159,11 +159,11 @@ if ($resql) { $thirdpartystatic->idprof5 = $obj->idprof5; $thirdpartystatic->idprof6 = $obj->idprof6; - print ''; - print ''; @@ -225,17 +225,17 @@ if ($result) { while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); - - print ''; - - print "'; + + print '\n"; print '\n"; - print '\n"; + print '\n"; print '\n"; print "\n"; diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 9c30db6e08a..8ee4c854600 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -143,7 +143,8 @@ if ($resql) { print price($total); print ''; print "
'.$langs->trans('Type').''; + print '
'.$langs->trans('Type').''; print ''; print $object->getLibType(); print ''; if ($object->module_source) { - print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; + print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; } if ($object->type == $object::TYPE_REPLACEMENT) { if ($type == 'bank-transfer') { @@ -409,16 +409,16 @@ if ($object->id > 0) { $facreplaced = new Facture($db); } $facreplaced->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; + print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).''; } - if ($object->type == $object::TYPE_CREDIT_NOTE) { + if ($object->type == $object::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { if ($type == 'bank-transfer') { $facusing = new FactureFournisseur($db); } else { $facusing = new Facture($db); } $facusing->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; + print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; } $facidavoir = $object->getListIdAvoirFromInvoice(); @@ -433,20 +433,22 @@ if ($object->id > 0) { $facavoir->fetch($facid); $invoicecredits[] = $facavoir->getNomUrl(1); } - print ' ('.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits) . ')'; + print ' '.$langs->transnoentities("InvoiceHasAvoir"); + print ' '. (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); + print ''; } /* - if ($facidnext > 0) - { + if ($objectidnext > 0) { $facthatreplace=new Facture($db); - $facthatreplace->fetch($facidnext); - print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; + $facthatreplace->fetch($objectidnext); + print ' '.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).''; } */ print '
'.$langs->trans('Discounts').''; + // Relative and absolute discounts + print ''."\n"; + print '
'.$langs->trans('DiscountStillRemaining').''; if ($type == 'bank-transfer') { //$societe = new Fournisseur($db); @@ -667,7 +669,7 @@ if ($object->id > 0) { // Total with tax print '
'.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans('RemainderToPay').''.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).'
'.price(price2num($x_paye_sum, 'MT')).'
'.$langs->trans("SubTotal").':'.price(price2num($subtotalcoll, 'MT')).''.price(price2num($subtotalpaye, 'MT')).''.price(price2num($subtotalpaid, 'MT')).''.price(price2num($subtotal, 'MT')).' 
'; $form->select_comptes($search_account, 'search_account', 0, '', 1); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index ae4064462e2..f63d58db933 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -79,8 +79,8 @@ class Paiement extends CommonObject public $pos_change = 0; // Excess received in TakePOS cash payment public $author; - public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement - public $paiementcode; // Code of payment. + public $paiementid; // ID of mode of payment. Is saved into fields fk_paiement on llx_paiement = id of llx_c_paiement + public $paiementcode; // Code of mode of payment. /** * @var string Type of payment label @@ -109,6 +109,16 @@ class Paiement extends CommonObject */ public $ext_payment_id; + /** + * @var string Id of prelevement + */ + public $id_prelevement; + + /** + * @var string num_prelevement + */ + public $num_prelevement; + /** * @var string Name of external payment mode */ diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index cf02c2aeb74..326be7144a8 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -102,7 +102,7 @@ $syear = GETPOST("reyear") ?GETPOST("reyear") : date("Y", time()); print $formother->select_month($cmonth, 'remonth'); -print $formother->select_year($syear, 'reyear'); +print $formother->selectyear($syear, 'reyear'); print ''; print ''; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 7cd49a9427c..db48b2767f2 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -198,7 +198,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print '
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'; + print '
'; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; + print ''; print $thirdpartystatic->getNomUrl(1, 'supplier'); print '
"; + print ''; $bprev->id = $obj->rowid; $bprev->ref = $obj->ref; $bprev->statut = $obj->statut; print $bprev->getNomUrl(1); print "'.dol_print_date($db->jdate($obj->datec), "dayhour")."'.price($obj->amount)."'.price($obj->amount)."'.$bprev->getLibStatut(3)."
'.$langs->trans("TransData").''; print dol_print_date($object->date_trans, 'day'); - print ' '.$langs->trans("By").' '.$muser->getNomUrl(-1).'
'.$langs->trans("TransMetod").''; print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); print '
'; + print '
'; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; + print ''; print $thirdpartystatic->getNomUrl(1, 'customer'); print '
"; $bprev->id = $obj->rowid; $bprev->ref = $obj->ref; $bprev->statut = $obj->statut; + + print '
'; print $bprev->getNomUrl(1); print "'.dol_print_date($db->jdate($obj->datec), "dayhour")."'.price($obj->amount)."'.price($obj->amount)."'.$bprev->getLibStatut(3)."
 
"; - $db->free(); + + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index d98a6aab251..4bd79a3c0d5 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; // Load translation files required by the page $langs->load("companies"); -if (!empty($conf->facture->enabled)) { +if (isModEnabled('facture')) { $langs->load("bills"); } @@ -116,7 +116,7 @@ if ($id > 0) { dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1); print dol_get_fiche_end(); - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->rights->facture->lire) { // Invoice list print load_fiche_titre($langs->trans("CustomerPreview")); @@ -158,7 +158,7 @@ if ($id > 0) { print $fac->error."
"; continue; } - $totalpaye = $fac->getSommePaiement(); + $totalpaid = $fac->getSommePaiement(); $userstatic->id = $objf->userid; $userstatic->login = $objf->login; @@ -168,7 +168,7 @@ if ($id > 0) { 'date' => $fac->date, 'datefieldforsort' => $fac->date.'-'.$fac->ref, 'link' => $fac->getNomUrl(1), - 'status' => $fac->getLibStatut(2, $totalpaye), + 'status' => $fac->getLibStatut(2, $totalpaid), 'amount' => $fac->total_ttc, 'author' => $userstatic->getLoginUrl(1) ); diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 68068dec866..719b1deb29a 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -212,7 +212,7 @@ if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { $subtotal_ht = 0; $subtotal_ttc = 0; -if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { +if (isModEnabled('facture') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -269,7 +269,7 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod // Nothing from this table } -if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { +if (isModEnabled('facture') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { // On ajoute les paiements clients anciennes version, non lies par paiement_facture if ($modecompta != 'CREANCES-DETTES') { $sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm"; @@ -324,7 +324,7 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod $subtotal_ht = 0; $subtotal_ttc = 0; -if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { +if (isModEnabled('facture') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 0ea9b1ba30d..fed5a42c04e 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -166,8 +166,8 @@ if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { // Delete social contribution if ($action == 'confirm_delete' && $confirm == 'yes') { $object->fetch($id); - $totalpaye = $object->getSommePaiement(); - if (empty($totalpaye)) { + $totalpaid = $object->getSommePaiement(); + if (empty($totalpaid)) { $result = $object->delete($user); if ($result > 0) { header("Location: list.php"); @@ -332,7 +332,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formsocialcontrib = new FormSocialContrib($db); $bankaccountstatic = new Account($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -406,7 +406,7 @@ if ($action == 'create') { print '
'.img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($fk_user, 'userid', 1).'
'.price($objp->amount)."
'.$langs->trans("AlreadyPaid").' :'.price($totalpaye)."
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid)."
'.$langs->trans("AmountExpected").' :'.price($object->amount)."
'.$langs->trans("RemainderToPay")." :
'; -print '
'; -print ''; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ''."\n"; +print '
'."\n"; + +print ''."\n"; // End of page llxFooter(); diff --git a/htdocs/compta/sociales/note.php b/htdocs/compta/sociales/note.php index cf9d0cbdec5..8ede1c3b502 100644 --- a/htdocs/compta/sociales/note.php +++ b/htdocs/compta/sociales/note.php @@ -25,7 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -93,7 +93,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' : '; if (!empty($object->fk_project)) { @@ -113,7 +113,9 @@ if ($id > 0 || !empty($ref)) { // ------------------------------------------------------------ $linkback = ''.$langs->trans("BackToList").''; - //$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + //$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + $morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 43e9d5d4668..d2646d241ea 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -137,7 +137,7 @@ print ''; $sql = "SELECT c.id, c.libelle as type_label,"; $sql .= " cs.rowid, cs.libelle as label_sc, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total, cs.paye,"; -$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; +$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pct.code as payment_code,"; $sql .= " u.rowid uid, u.lastname, u.firstname, u.email, u.login, u.admin,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos"; @@ -253,7 +253,7 @@ if (!$resql) { $i = 0; $total = 0; $totalnb = 0; -$totalpaye = 0; +$totalpaid = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -346,8 +346,8 @@ while ($i < min($num, $limit)) { // Paid print ''; - if ($obj->totalpaye) { - print ''.price($obj->totalpaye).''; + if ($obj->totalpaid) { + print ''.price($obj->totalpaid).''; } print ''; @@ -357,7 +357,7 @@ while ($i < min($num, $limit)) { $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; + $totalpaid = $totalpaid + $obj->totalpaid; $i++; } @@ -373,7 +373,7 @@ if (!empty($conf->banque->enabled)) { print ''; print ''; } -print ''.price($totalpaye).""; +print ''.price($totalpaid).""; print ''; print ""; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 35d5028e938..2b8f40b3aba 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -484,7 +484,7 @@ if (count($amount)) { if (!empty($conf->commande->enabled) && $key > 0) { print ' '.img_picto($langs->trans("OrderStats"), "stats").' '; } - if (!empty($conf->facture->enabled) && $key > 0) { + if (isModEnabled('facture') && $key > 0) { print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' '; } print ''; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 0bef7ff555a..320efa36ed6 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -179,6 +179,7 @@ $allparams = array_merge($commonparams, $headerparams, $tableparams); $headerparams = array_merge($commonparams, $headerparams); $tableparams = array_merge($commonparams, $tableparams); +$paramslink=""; foreach ($allparams as $key => $value) { $paramslink .= '&'.$key.'='.$value; } @@ -202,6 +203,9 @@ if ($modecompta == "BOOKKEEPINGCOLLECTED") { $modecompta = "RECETTES-DEPENSES"; } +$exportlink=""; +$namelink=""; + // Show report header if ($modecompta == "CREANCES-DETTES") { $name = $langs->trans("Turnover").', '.$langs->trans("ByThirdParties"); @@ -654,7 +658,7 @@ if (count($amount)) { if (!empty($conf->commande->enabled) && $key > 0) { print ' '.img_picto($langs->trans("OrderStats"), "stats").' '; } - if (!empty($conf->facture->enabled) && $key > 0) { + if (isModEnabled('facture') && $key > 0) { print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' '; } print ''; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index e7ec8c61db7..b99002fe609 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -144,6 +144,8 @@ llxHeader(); $form = new Form($db); +$exportlink=""; +$namelink=""; // Affiche en-tete du rapport if ($modecompta == "CREANCES-DETTES") { $name = $langs->trans("Turnover"); @@ -254,6 +256,11 @@ $sql .= " ORDER BY dm"; $minyearmonth = $maxyearmonth = 0; +$cum = array(); +$cum_ht = array(); +$total_ht = array(); +$total = array(); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -395,6 +402,12 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m"); $caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m"); + $total_ht[$annee]=0; + $total[$annee]=0; + $cum_ht[$case]=0; + $cum[$case]=0; + + if ($annee >= $year_start) { // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output. if ($modecompta == 'CREANCES-DETTES') { // Value turnover of month w/o VAT diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ed37c72c1c4..e40b9b9b409 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -273,9 +273,9 @@ if ($action == 'add' && !$cancel) { if ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); - if (empty($totalpaye)) { + if (empty($totalpaid)) { $db->begin(); $ret = $object->delete($user); @@ -540,7 +540,7 @@ if ($action == 'create') { if ($id > 0) { $head = vat_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); // Clone confirmation if ($action === 'clone') { @@ -580,7 +580,7 @@ if ($id > 0) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); @@ -683,7 +683,7 @@ if ($id > 0) { //print $sql; $resql = $db->query($sql); if ($resql) { - $totalpaye = 0; + $totalpaid = 0; $num = $db->num_rows($resql); $i = 0; @@ -735,7 +735,7 @@ if ($id > 0) { } print ''.price($objp->amount)."\n"; print ""; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { @@ -744,10 +744,10 @@ if ($id > 0) { print ''; } - print ''.$langs->trans("AlreadyPaid")." :".price($totalpaye)."\n"; + print ''.$langs->trans("AlreadyPaid")." :".price($totalpaid)."\n"; print ''.$langs->trans("AmountExpected")." :".price($object->amount)."\n"; - $resteapayer = $object->amount - $totalpaye; + $resteapayer = $object->amount - $totalpaid; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; print ''.$langs->trans("RemainderToPay")." :"; @@ -810,7 +810,7 @@ if ($id > 0) { print '"; } - if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaye)) { + if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaid)) { print ''; } else { print ''; @@ -853,7 +853,7 @@ if ($id > 0) { /* $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 8eaf141b06c..b7500fffaa0 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -96,6 +96,28 @@ class PaymentVAT extends CommonObject */ public $fk_user_modif; + /** + * @var int ID + */ + public $chid; + + /** + * @var string lib + * @deprecated + * @see $label + */ + public $lib; + + /** + * @var integer|string datepaye + */ + public $datepaye; + + /** + * @var integer|string paiementtype + */ + public $paiementtype; + /** * Constructor * diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 30682fa15b4..f54ed42fb06 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -49,6 +49,12 @@ class Tva extends CommonObject */ public $picto = 'payment'; + /** + * @deprecated + * @see $amount + */ + public $total; + public $tms; public $datep; public $datev; @@ -56,6 +62,11 @@ class Tva extends CommonObject public $type_payment; public $num_payment; + /** + * @var integer|string totalpaid + */ + public $totalpaid; + /** * @var string label */ @@ -81,6 +92,11 @@ class Tva extends CommonObject */ public $fk_user_modif; + /** + * @var integer|string paiementtype + */ + public $paiementtype; + const STATUS_UNPAID = 0; const STATUS_PAID = 1; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index a0573cf2812..dc362e60051 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -102,7 +102,7 @@ if ($action == 'setlib' && $permissiontoadd) { */ $form = new Form($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -125,8 +125,9 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index fed0cf209c1..16b24361160 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -255,7 +255,7 @@ if ($refresh === true) { //var_dump($m); $total = 0; $subtotalcoll = 0; - $subtotalpaye = 0; + $subtotalpaid = 0; $subtotal = 0; $i = 0; $mcursor = 0; @@ -481,7 +481,7 @@ if ($refresh === true) { print '' . price(price2num($x_paye_sum, 'MT')) . ''; $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalpaid = $subtotalpaid + $x_paye_sum; $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; @@ -498,12 +498,12 @@ if ($refresh === true) { print ''; print '' . $langs->trans("SubTotal") . ':'; print '' . price(price2num($subtotalcoll, 'MT')) . ''; - print '' . price(price2num($subtotalpaye, 'MT')) . ''; + print '' . price(price2num($subtotalpaid, 'MT')) . ''; print '' . price(price2num($subtotal, 'MT')) . ''; print ' '; $i = 0; $subtotalcoll = 0; - $subtotalpaye = 0; + $subtotalpaid = 0; $subtotal = 0; } } diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index f1731420852..5f76b2e9190 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -190,8 +190,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { @@ -202,15 +202,15 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); -$result = $db->query($sql); -if (!$result) { +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); llxFooter(); $db->close(); exit; } -$num = $db->num_rows($result); +$num = $db->num_rows($resql); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { @@ -429,7 +429,7 @@ print ''; $i = 0; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; @@ -549,11 +549,27 @@ $totalarray['nbfield']++; // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; -print ''; -print '
'; -print ''; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} -$db->free($result); +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ''."\n"; +print ''."\n"; + +print ''."\n"; // End of page llxFooter(); diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index cf91df3a775..0279acdeaa4 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -141,7 +141,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $sql = "SELECT tva.rowid, tva.label as label, b.fk_account, ptva.fk_bank"; $sql .= ", tva.datev"; $sql .= ", tva.amount as total,"; - $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,"; + $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaid, ptva.num_paiement as num_payment,"; $sql .= " pct.code as payment_code"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as tva,"; $sql .= " ".MAIN_DB_PREFIX."payment_vat as ptva"; @@ -175,11 +175,15 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $i = 0; $total = 0; $totalnb = 0; - $totalpaye = 0; + $totalpaid = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); + $tva->id = $obj->rowid; + $tva->ref = $obj->rowid; + $tva->label = $obj->label; + $payment_vat_static->id = $obj->pid; $payment_vat_static->ref = $obj->pid; @@ -190,31 +194,32 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // VAT print ''; - $tva->id = $obj->rowid; - $tva->ref = $obj->rowid; - $tva->label = $obj->label; print $tva->getNomUrl(1, '20'); print ''; // Label - print ''.$obj->label.''; + print ''.dol_escape_htmltag($obj->label).''; // Date - $date = $obj->datev; - print ''.dol_print_date($date, 'day').''; + $date = $db->jdate($obj->datev); + print ''.dol_print_date($date, 'day').''; // Date payment - print ''.dol_print_date($db->jdate($obj->datep), 'day').''; + $datep = $db->jdate($obj->datep); + print ''.dol_print_date($datep, 'day').''; // Type payment - print ''; + $labelpaymenttype = ''; if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + $labelpaymenttype = $langs->trans("PaymentTypeShort".$obj->payment_code).' '; } + + print ''; + print dol_escape_htmltag($labelpaymenttype); print ''; // Chq number - print ''.$obj->num_payment.''; + print ''.dol_escape_htmltag($obj->num_payment).''; if (!empty($conf->banque->enabled)) { // Bank transaction @@ -231,21 +236,20 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; } - // Type - //print ''.$obj->type_label.''; // Expected to pay print ''.price($obj->total).''; + // Paid print ''; - if ($obj->totalpaye) { - print price($obj->totalpaye); + if ($obj->totalpaid) { + print price($obj->totalpaid); } print ''; print ''; $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; + $totalpaid = $totalpaid + $obj->totalpaid; $i++; } @@ -260,7 +264,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { } print ' '; print ' '; - print ''.price($totalpaye).""; + print ''.price($totalpaid).""; print ""; } else { dol_print_error($db); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 0eed6ba6219..5f07922b2e4 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -251,23 +251,23 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $objthirdparty = $object->thirdparty; $out = ''; - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { - $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); - } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); - $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); - } - $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) { + if (isModEnabled('agenda')) { + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { + $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); + } + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); + $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); + } + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; $param = '&id='.$id; diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 195a4d028f4..a72ea3d7d21 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -206,7 +206,7 @@ abstract class ActionsContactCardCommon $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); $i++; } - if (!empty($conf->facture->enabled)) { + if (isModEnabled('facture')) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); $i++; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index ee1d10181ca..09d46d02b13 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -235,6 +236,9 @@ if (empty($reshook)) { $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); $object->birthday_alert = GETPOST("birthday_alert", 'alpha'); + //Default language + $object->default_lang = GETPOST('default_lang'); + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { @@ -316,8 +320,9 @@ if (empty($reshook)) { $result = $object->delete(); // TODO Add $user as first param if ($result > 0) { - if ($backtopage) { - header("Location: ".$backtopage); + setEventMessages("RecordDeleted", null, 'mesgs'); + if ($backurlforlist) { + header("Location: ".$backurlforlist); exit; } else { header("Location: ".DOL_URL_ROOT.'/contact/list.php'); @@ -436,6 +441,9 @@ if (empty($reshook)) { $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty + //Default language + $object->default_lang = GETPOST('default_lang'); + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) { @@ -556,6 +564,7 @@ if (empty($reshook)) { */ $form = new Form($db); +$formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); @@ -634,7 +643,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->country = $tmparray['label']; } - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")); $linkback = ''; print load_fiche_titre($title, $linkback, 'address'); @@ -856,7 +865,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($value['icon'])) { print ''; } - print ''; + print ''; print ''; print ''; } elseif (!empty($object->socialnetworks[$key])) { @@ -871,6 +880,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); print ''; + //Default language + if (!empty($conf->global->MAIN_MULTILANGS)) { + print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; + print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone', 0, 0, 0, null, 1); + + print ''; + print ''; + } + // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print ''.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; @@ -1021,7 +1039,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; print '
'; - print ''; + print ''; print '
'; if ($conf->use_javascript_ajax) { print ''.$langs->trans('CopyAddressFromSoc').'
'; @@ -1150,6 +1168,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $form->selectarray('priv', $selectarray, $object->priv, 0); print ''; + //Default language + if (!empty($conf->global->MAIN_MULTILANGS)) { + print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; + print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + + print ''; + print ''; + } + // Note Public print ''; $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); @@ -1214,7 +1241,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } - if (!empty($conf->facture->enabled)) { + if (isModEnabled('facture')) { print ''.$langs->trans("ContactForInvoices").''; print $object->ref_facturation ? $object->ref_facturation : (''.$langs->trans("NoContactForAnyInvoice").''); print ''; @@ -1362,6 +1389,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } + // Default language + if (!empty($conf->global->MAIN_MULTILANGS)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print ''.$langs->trans("DefaultLang").''; + //$s=picto_from_langcode($object->default_lang); + //print ($s?$s.' ':''); + $langs->load("languages"); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang.'_'.strtoupper($object->default_lang)) : ''); + print $labellang; + print ''; + } + print ''.$langs->trans("ContactVisibility").''; print $object->LibPubPriv($object->priv); print ''; @@ -1472,7 +1511,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } - if (!empty($conf->facture->enabled)) { + if (isModEnabled('facture')) { print ''.$langs->trans("ContactForInvoices").''; print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print ''; @@ -1550,7 +1589,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $MAXEVENT = 10; - $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); + $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 487c075b3a1..9fa3602ee4b 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -130,6 +130,13 @@ class Contact extends CommonObject public $civility_code; public $civility; + /** + * @var string The civilite code, not an integer + * @deprecated + * @see $civility_code + */ + public $civilite; + /** * @var string Address */ @@ -181,6 +188,12 @@ class Contact extends CommonObject */ public $email; + /** + * URL + * @var string + */ + public $url; + /** * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings * @var int @@ -315,6 +328,7 @@ class Contact extends CommonObject */ public $stcomm_picto; + /** * Constructor * @@ -1461,13 +1475,6 @@ class Contact extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('contactdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } $linkstart = ''; if ($object->thirdparty->client) { $thirdTypeArray['customer'] = $langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); } - if ($conf->commande->enabled && $user->rights->commande->lire) { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); } - if ($conf->facture->enabled && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->rights->facture->lire) { $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); } - if ($conf->contrat->enabled && $user->rights->contrat->lire) { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } } @@ -355,7 +355,7 @@ if (empty($elementTypeArray) && !$object->thirdparty->client && !$object->thirdp // Define type of elements $typeElementString = $form->selectarray("type_element", $elementTypeArray, GETPOST('type_element'), $showempty, 0, 0, '', 0, 0, $disabled, '', 'maxwidth150onsmartphone'); -$button = ''; +$button = ''; $param = ''; $param .= "&sref=".urlencode($sref); @@ -366,7 +366,7 @@ $param .= "&socid=".urlencode($socid); $param .= "&type_element=".urlencode($type_element); $total_qty = 0; - +$num=0; if ($sql_select) { $resql = $db->query($sql); if (!$resql) { @@ -410,7 +410,7 @@ if ($sql_select) { print ''; print ''; // date print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1); print ''; print ''; print ''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 31b2153c2c8..e68274ecff2 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -132,31 +132,31 @@ if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('b } $offset = $limit * $page; -$titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); if ($type == "p") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactprospectlist'; } - $titre .= ' ('.$langs->trans("ThirdPartyProspects").')'; + $title .= ' ('.$langs->trans("ThirdPartyProspects").')'; $urlfiche = "card.php"; } if ($type == "c") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactcustomerlist'; } - $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')'; + $title .= ' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche = "card.php"; } elseif ($type == "f") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactsupplierlist'; } - $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')'; + $title .= ' ('.$langs->trans("ThirdPartySuppliers").')'; $urlfiche = "card.php"; } elseif ($type == "o") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactotherlist'; } - $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; + $title .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; $urlfiche = ""; } @@ -709,7 +709,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "contact"; @@ -1309,19 +1309,31 @@ while ($i < min($num, $limit)) { $i++; } +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print ""; -print "
"; - -//if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1); - -print ''; +print ''."\n"; +print ''."\n"; +print ''."\n"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index b725ef6f3f4..71483f6b1aa 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index 70d3193c12f..cc4cf23e37b 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index d654ac38d9f..a8dc5e7ee3b 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -110,7 +110,7 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -171,7 +171,7 @@ if ($id > 0) { $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { @@ -243,7 +243,7 @@ if ($id > 0) { $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) { + if (isModEnabled('agenda')) { if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { $backtopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out = '&origin='.$object->element.'&originid='.$object->id.'&backtopage='.urlencode($backtopage); @@ -251,7 +251,7 @@ if ($id > 0) { } } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; $param = '&id='.$id; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7265a69d1af..ecc8ec22660 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (!empty($conf->propal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; } -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -264,10 +264,6 @@ if (empty($reshook)) { } $id = $object->create($user); - if ($id < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); @@ -379,6 +375,9 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } + if ($error) { + $action = 'create'; + } } else { $result = $object->create($user); if ($result > 0) { @@ -1003,7 +1002,7 @@ llxHeader('', $langs->trans("Contract"), $help_url); $form = new Form($db); $formfile = new FormFile($db); -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } @@ -1162,7 +1161,7 @@ if ($action == 'create') { print ""; // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load('projects'); $formproject = new FormProjets($db); @@ -1322,7 +1321,7 @@ if ($action == 'create') { $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { @@ -2072,7 +2071,7 @@ if ($action == 'create') { } } - if (!empty($conf->facture->enabled) && $object->statut > 0) { + if (isModEnabled('facture') && $object->statut > 0) { $langs->load("bills"); if ($user->rights->facture->creer) { print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params); @@ -2161,7 +2160,7 @@ if ($action == 'create') { $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 5e534f3e43c..ea228550cae 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -278,8 +278,8 @@ class Contracts extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->price_base_type = checkVal($request_data->price_base_type); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->price_base_type = sanitizeVal($request_data->price_base_type); $updateRes = $this->contract->addline( $request_data->desc, @@ -336,8 +336,8 @@ class Contracts extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->price_base_type = checkVal($request_data->price_base_type); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->price_base_type = sanitizeVal($request_data->price_base_type); $updateRes = $this->contract->updateline( $lineid, diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d85ad51946a..8b6d7490eaf 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -232,8 +232,8 @@ class Contrat extends CommonObject 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>75), 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative follower', 'enabled'=>1, 'visible'=>-1, 'position'=>85), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), @@ -772,16 +772,6 @@ class Contrat extends CommonObject $now = dol_now(); - /* - if (!is_object($extrafields)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - } - - $line = new ContratLigne($this->db); - $extrafields->fetch_name_optionals_label(ContratLigne::$table_element, true); - */ - $this->lines = array(); $pos = 0; @@ -875,15 +865,17 @@ class Contrat extends CommonObject $line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite); $line->date_fin_reel = $this->db->jdate($objp->date_cloture); - // Retrieve all extrafields for contract + // Retrieve all extrafields for contract line // fetch optionals attributes and labels $line->fetch_optionals(); // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$pos] = $line; @@ -2698,6 +2690,7 @@ class ContratLigne extends CommonObjectLine public $date_cloture; // date end real public $tva_tx; + public $vat_src_code; public $localtax1_tx; public $localtax2_tx; public $localtax1_type; // Local tax 1 type @@ -2754,6 +2747,7 @@ class ContratLigne extends CommonObjectLine public $commentaire; + const STATUS_INITIAL = 0; const STATUS_OPEN = 4; const STATUS_CLOSED = 5; @@ -2998,7 +2992,6 @@ class ContratLigne extends CommonObjectLine $this->localtax2_type = $obj->localtax2_type; $this->qty = $obj->qty; $this->remise_percent = $obj->remise_percent; - $this->remise = $obj->remise; $this->fk_remise_except = $obj->fk_remise_except; $this->subprice = $obj->subprice; $this->price_ht = $obj->price_ht; @@ -3056,7 +3049,6 @@ class ContratLigne extends CommonObjectLine $this->localtax2_tx = trim($this->localtax2_tx); $this->qty = trim($this->qty); $this->remise_percent = trim($this->remise_percent); - $this->remise = trim($this->remise); $this->fk_remise_except = (int) $this->fk_remise_except; $this->subprice = price2num($this->subprice); $this->price_ht = price2num($this->price_ht); diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index d053a9a4fa0..1bd9d3388f6 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -154,7 +154,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 953fd0002d2..ce386fe21b9 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -144,7 +144,7 @@ if ($object->id) { $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 99739260b36..1b9ab289774 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -346,22 +346,28 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); + $datem = $db->jdate($obj->tms); + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); + $staticcontrat->id = $obj->cid; + + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; print ''; print ''; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); - $staticcontrat->id = $obj->cid; print $staticcontrat->getNomUrl(1, 16); if ($obj->nb_late) { print img_warning($langs->trans("Late")); } print ''; - print ''; - $staticcompany->id = $obj->socid; - $staticcompany->name = $obj->name; + + print ''; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''.dol_print_date($db->jdate($obj->tms), 'dayhour').''; + print ''; + print dol_print_date($datem, 'dayhour'); + print ''; //print ''.$staticcontrat->LibStatut($obj->statut,2).''; print ''.($obj->nb_initial > 0 ? ''.$obj->nb_initial.''.$staticcontratligne->LibStatut(0, 3, -1, 'class="paddingleft"') : '').''; print ''.($obj->nb_running > 0 ? ''.$obj->nb_running.''.$staticcontratligne->LibStatut(4, 3, 0, 'class="marginleft"') : '').''; @@ -439,7 +445,7 @@ if ($resql) { } } print ''; - print ''; + print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); @@ -451,7 +457,7 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + $db->free($resql); print ""; } else { @@ -521,7 +527,7 @@ if ($resql) { } } print ''; - print ''; + print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); @@ -532,7 +538,8 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + + $db->free($resql); print ""; } else { @@ -603,7 +610,7 @@ if ($resql) { } } print ''; - print ''; + print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); @@ -614,7 +621,7 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + $db->free($resql); print ""; } else { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 57b4657eab4..e76261010da 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -693,7 +693,7 @@ if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print '
'; print $formother->select_month($search_dfmonth, 'search_dfmonth', 1, 0); print ' '; - $formother->select_year($search_dfyear, 'search_dfyear', 1, 20, 5, 0, 0, ''); + print $formother->selectyear($search_dfyear, 'search_dfyear', 1, 20, 5, 0, 0, ''); print ''; } // Status diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 01378a65786..540491698c1 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -27,7 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -111,7 +111,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 1f3ccf70f3a..530457f45fa 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -486,7 +486,7 @@ $morefilter = ''; $moreforfilter = ''; // If the user can view categories of products -if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { +if (isModEnabled('categorie') && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b3c96312ba6..95f3cb28fd8 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -28,8 +28,14 @@ // $permissiontodelete must be defined // $backurlforlist must be defined // $backtopage may be defined +// $noback may be defined // $triggermodname may be defined +$hidedetails = isset($hidedetails) ? $hidedetails : ''; +$hidedesc = isset($hidedesc) ? $hidedesc : ''; +$hideref = isset($hideref) ? $hideref : ''; + + if (!empty($permissionedit) && empty($permissiontoadd)) { $permissiontoadd = $permissionedit; // For backward compatibility } @@ -107,10 +113,10 @@ if ($action == 'add' && !empty($permissiontoadd)) { //var_dump($key.' '.$value.' '.$object->fields[$key]['type']); $object->$key = $value; - if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { + if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && isset($val['default']) && $val['default'] == '(PROV)') { $object->$key = '(PROV)'; } - if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { + if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && !isset($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } @@ -127,7 +133,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { // Fill array 'array_options' with data from add form if (!$error) { - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '', 1); if ($ret < 0) { $error++; } @@ -137,14 +143,17 @@ if ($action == 'add' && !empty($permissiontoadd)) { $result = $object->create($user); if ($result > 0) { // Creation OK - if ($conf->categorie->enabled && method_exists($object, 'setCategories')) { + if (isModEnabled('categorie') && method_exists($object, 'setCategories')) { $categories = GETPOST('categories', 'array:int'); $object->setCategories($categories); } $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: ".$urltogo); - exit; + + if (empty($noback)) { + header("Location: " . $urltogo); + exit; + } } else { $error++; // Creation KO @@ -247,7 +256,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { } } - if ($conf->categorie->enabled) { + if (isModEnabled('categorie')) { $categories = GETPOST('categories', 'array'); if (method_exists($object, 'setCategories')) { $object->setCategories($categories); @@ -323,8 +332,10 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".$backurlforlist); - exit; + if (empty($noback)) { + header("Location: " . $backurlforlist); + exit; + } } else { $error++; if (!empty($object->errors)) { @@ -367,8 +378,10 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + if (empty($noback)) { + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + exit; + } } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); @@ -385,10 +398,10 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -506,8 +519,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) $newid = $result; } - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object - exit; + if (empty($noback)) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $newid); // Open record of new object + exit; + } } else { $error++; setEventMessages($objectutil->error, $objectutil->errors, 'errors'); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index c813e8af4a0..69d46dae51c 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -26,7 +26,7 @@ // $id must be defined // $object must be defined and must have a method generateDocument(). // $permissiontoadd must be defined -// $upload_dir must be defined (example $conf->projet->dir_output . "/";) +// $upload_dir must be defined (example $conf->project->dir_output . "/";) // $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not. if (!empty($permissioncreate) && empty($permissiontoadd)) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 383684b377a..9ec4db2bd11 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -31,7 +31,7 @@ // $parameters, $object, $action must be defined for the hook. // $permissiontoread, $permissiontoadd, $permissiontodelete, $permissiontoclose may be defined -// $uploaddir may be defined (example to $conf->projet->dir_output."/";) +// $uploaddir may be defined (example to $conf->project->dir_output."/";) // $toselect may be defined // $diroutputmassaction may be defined @@ -90,7 +90,7 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); } - if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdparty = new Adherent($db); } if ($objecttmp->element == 'holiday') { @@ -110,7 +110,7 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; } - if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdpartyid = $objecttmp->fk_member; } if ($objecttmp->element == 'holiday') { @@ -264,7 +264,7 @@ if (!$error && $massaction == 'confirm_presend') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; - } elseif ($objectobj->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + } elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objectobj->fk_member); $sendto = $fadherent->email; @@ -455,7 +455,7 @@ if (!$error && $massaction == 'confirm_presend') { //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); foreach ($looparray as $objectid => $objecttmp) { // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object // Make substitution in email content - if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) { + if (!empty($conf->project->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) { $objecttmp->fetch_projet(); } $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp); @@ -1468,6 +1468,7 @@ if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $ $trackid = 'leav'.$objecttmp->id; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); // Sending email diff --git a/htdocs/core/ajax/ajaxcompanies.php b/htdocs/core/ajax/ajaxcompanies.php new file mode 100644 index 00000000000..350f03398aa --- /dev/null +++ b/htdocs/core/ajax/ajaxcompanies.php @@ -0,0 +1,122 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * 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/core/ajax/ajaxcompanies.php + * \brief File to return Ajax response on third parties request + */ + +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); + +require '../../main.inc.php'; + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +//print ''."\n"; + +dol_syslog(join(',', $_GET)); + + +// Generation liste des societes +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { + $return_arr = array(); + + // Define filter on text typed + $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; + if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; + + $sql = "SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.address, s.zip, s.town, s.email, s.siren, s.siret, s.ape, s.idprof4, s.client, s.fournisseur, s.datec, s.logo"; + $sql .= " , c.label as country, d.nom as departement"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON d.rowid = s.fk_departement"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + if ($socid) { + $sql .= " AND ("; + // Add criteria on name/code + if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { // Can use index + $sql .= "s.nom LIKE '".$db->escape($socid)."%'"; + $sql .= " OR s.code_client LIKE '".$db->escape($socid)."%'"; + $sql .= " OR s.code_fournisseur LIKE '".$db->escape($socid)."%'"; + } else { + $sql .= "s.nom LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR s.code_client LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR s.code_fournisseur LIKE '%".$db->escape($socid)."%'"; + } + if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR s.rowid = '".$db->escape($socid)."'"; + $sql .= ")"; + } + //if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters + $sql .= " ORDER BY s.nom ASC"; + + //dol_syslog("ajaxcompanies", LOG_DEBUG); + $resql = $db->query($sql); + + if ($resql) { + while ($row = $db->fetch_array($resql)) { + $label = $row['nom']; + if ($socid) $label = $label; + $row_array['label'] = $label; + $row_array['value'] = $row['nom']; + $row_array['key'] = $row['rowid']; + $row_array['name_alias'] = $row['name_alias']; + $row_array['code_client'] = $row['code_client']; + $row_array['code_fournisseur'] = $row['code_fournisseur']; + $row_array['address'] = $row['address']; + $row_array['zip'] = $row['zip']; + $row_array['town'] = $row['town']; + $row_array['email'] = $row['email']; + $row_array['siren'] = $row['siren']; + $row_array['siret'] = $row['siret']; + $row_array['ape'] = $row['ape']; + $row_array['idprof4'] = $row['idprof4']; + $row_array['client'] = $row['client']; + $row_array['fournisseur'] = $row['fournisseur']; + $row_array['datec'] = $row['datec']; + $row_array['logo'] = $row['logo']; + $row_array['country'] = $row['country']; + $row_array['departement'] = $row['departement']; + + array_push($return_arr, $row_array); + } + + echo json_encode($return_arr); + } else { + echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); + } +} else { + echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); +} diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index c4b79d89920..ce47cc3568f 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -252,9 +252,9 @@ if ($type == 'directory') { } elseif ($module == 'salaries') { $upload_dir = $conf->salaries->dir_output; } elseif ($module == 'project') { - $upload_dir = $conf->projet->dir_output; + $upload_dir = $conf->project->dir_output; } elseif ($module == 'project_task') { - $upload_dir = $conf->projet->dir_output; + $upload_dir = $conf->project->dir_output; } elseif ($module == 'fichinter') { $upload_dir = $conf->ficheinter->dir_output; } elseif ($module == 'user') { diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index ce9ae57864d..994ba5c42f3 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -129,8 +129,12 @@ if ($action == "importSignature") { $pdf->AddPage(); $pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF - $tppl = $pdf->importPage(1); - $pdf->useTemplate($tppl); + for ($i=1;$i<($pagecount+1);$i++) { + if ($i>1) $pdf->AddPage(); + $tppl=$pdf->importPage($i); + $pdf->useTemplate($tppl); + } + $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset. $pdf->Close(); $pdf->Output($newpdffilename, "F"); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 383f9a0c041..fcc39e1aae1 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -48,7 +48,7 @@ if (!defined('NOREQUIRETRAN')) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; - +$hookmanager->initHooks(array('rowinterface')); // Security check // This is done later into view. @@ -120,7 +120,15 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } } - + $parameters = array('roworder'=> &$roworder, 'table_element_line' => &$table_element_line, 'fk_element' => &$fk_element, 'element_id' => &$element_id, 'perm' => &$perm); + $row = new GenericObject($db); + $row->table_element_line = $table_element_line; + $row->fk_element = $fk_element; + $row->id = $element_id; + $reshook = $hookmanager->executeHooks('checkRowPerms', $parameters, $row, $action); + if ($reshook > 0) { + $perm = $hookmanager->resArray['perm']; + } if (! $perm) { // We should not be here. If we are not allowed to reorder rows, feature should not be visible on script. // If we are here, it is a hack attempt, so we report a warning. @@ -137,10 +145,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) } } - $row = new GenericObject($db); - $row->table_element_line = $table_element_line; - $row->fk_element = $fk_element; - $row->id = $element_id; + $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index ae4f7c41515..c1199477f58 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -89,10 +89,10 @@ if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->glob $arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { +if (!empty($conf->project->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) { +if (!empty($conf->project->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) { $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } @@ -105,7 +105,7 @@ if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUS if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) { $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { +if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } @@ -120,7 +120,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S } // Customer payments -if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { +if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { $arrayresult['searchintocustomerpayments'] = array( 'position'=>170, 'img'=>'object_payment', diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 371a7a0dbed..ea43eff12fc 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -62,7 +62,7 @@ class box_activity extends ModeleBoxes // FIXME: Pb into some status $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) - $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire) + $this->hidden = !((isModEnabled('facture') && $user->rights->facture->lire) || (!empty($conf->commande->enabled) && $user->rights->commande->lire) || (!empty($conf->propal->enabled) && $user->rights->propale->lire) ); @@ -278,7 +278,7 @@ class box_activity extends ModeleBoxes // list the summary of the bills - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facturestatic = new Facture($this->db); @@ -329,7 +329,7 @@ class box_activity extends ModeleBoxes if (!empty($data)) { $j = 0; while ($j < count($data)) { - $billurl = "search_status=2&paye=1&year=".$data[$j]->annee; + $billurl = "search_status=2&paye=1"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), @@ -339,7 +339,7 @@ class box_activity extends ModeleBoxes $this->info_box_contents[$line][1] = array( 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee, + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), ); $this->info_box_contents[$line][2] = array( diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index d96fac8bc76..a9a4f8746da 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -147,7 +147,7 @@ class box_boms extends ModeleBoxes } $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 2afa630860b..4a7ea965006 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -140,7 +140,7 @@ class box_clients extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel') ); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index b2ba608d689..ea35a080d0e 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -177,7 +177,7 @@ class box_contacts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 8eeb1b93323..dddafffdc02 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -83,8 +83,8 @@ class box_contracts extends ModeleBoxes $thirdpartytmp = new Societe($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,"; + $sql .= " c.ref_customer, c.ref_supplier"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -117,6 +117,7 @@ class box_contracts extends ModeleBoxes $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->date_modification); $dateterm = $this->db->jdate($objp->fin_validite); $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; @@ -155,8 +156,8 @@ class box_contracts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day', 'tzuserrel'), + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', + 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 24be4100dab..b25a42228e7 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -126,14 +126,14 @@ class box_dolibarr_state_board extends ModeleBoxes 'services' => !empty($conf->service->enabled) && $user->rights->service->lire, 'proposals' => !empty($conf->propal->enabled) && $user->rights->propale->lire, 'orders' => !empty($conf->commande->enabled) && $user->rights->commande->lire, - 'invoices' => !empty($conf->facture->enabled) && $user->rights->facture->lire, + 'invoices' => isModEnabled('facture') && $user->rights->facture->lire, 'donations' => !empty($conf->don->enabled) && $user->rights->don->lire, 'contracts' => !empty($conf->contrat->enabled) && $user->rights->contrat->lire, 'interventions' => !empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, 'supplier_orders' => !empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), 'supplier_invoices' => !empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), 'supplier_proposals' => !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), - 'projects' => !empty($conf->projet->enabled) && $user->rights->projet->lire, + 'projects' => !empty($conf->project->enabled) && $user->rights->projet->lire, 'expensereports' => !empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, 'holidays' => !empty($conf->holiday->enabled) && $user->rights->holiday->read, 'ticket' => !empty($conf->ticket->enabled) && $user->rights->ticket->read, diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index aff48328edb..2a04aa27803 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -127,7 +127,7 @@ class box_external_rss extends ModeleBoxes // Feed common fields $href = $item['link']; $title = urldecode($item['title']); - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + $date = empty($item['date_timestamp']) ? null : $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') { // If RSS if (!$date && isset($item['pubdate'])) { $date = $item['pubdate']; 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 5c8bd2c8555..b75d0752334 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 @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_graph_nb_ticket_last_x_days extends ModeleBoxes { - public $boxcode = "box_nb_ticket_last_x_days"; + public $boxcode = "box_graph_nb_ticket_last_x_days"; public $boximg = "ticket"; public $boxlabel; public $depends = array("ticket"); @@ -102,18 +102,17 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes 'text' => $text, 'limit' => dol_strlen($text) ); - $today = date_time_set(date_create(), 0, 0); - $todayformat = date('Y-m-d', date_timestamp_get($today)); - $intervaltosub = new DateInterval('P'.dol_escape_htmltag($days - 1).'D'); - $intervaltoadd = new DateInterval('P1D'); - $minimumdatec = date_sub($today, $intervaltosub); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $today = dol_now(); + $intervaltoadd = 1; + $minimumdatec = dol_time_plus_duree($today, -1 * ($days - 1), 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); if ($user->rights->ticket->read) { $sql = "SELECT CAST(t.datec AS DATE) as datec, COUNT(t.datec) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " WHERE CAST(t.datec AS DATE) > DATE_SUB(CURRENT_DATE, INTERVAL ".$days." DAY)"; + $sql .= " WHERE CAST(t.datec AS DATE) > '".$this->db->idate($minimumdatec)."'"; $sql .= " GROUP BY CAST(t.datec AS DATE)"; + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -122,18 +121,18 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes $objp = $this->db->fetch_object($resql); while ($minimumdatecformated < $objp->datec) { $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); - $minimumdatec = date_add($minimumdatec, $intervaltoadd); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); } $dataseries[] = array('label' => dol_print_date($objp->datec, 'day'), 'data' => $objp->nb); - $minimumdatec = date_add($minimumdatec, $intervaltoadd); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); $i++; } while (count($dataseries) < $days) { $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); - $minimumdatec = date_add($minimumdatec, $intervaltoadd); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); $i++; } } else { diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 2da54d84e7a..6b25f5d84d0 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_graph_nb_tickets_type extends ModeleBoxes { - public $boxcode = "box_nb_tickets_type"; + public $boxcode = "box_graph_nb_tickets_type"; public $boximg = "ticket"; public $boxlabel; public $depends = array("ticket"); @@ -131,7 +131,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes } foreach ($listofoppcode as $rowid => $code) { $dataseries[] = array( - 'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_category', 'code', 'label', $code), + 'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_type', 'code', 'label', $code), 'data' => (empty($data[$code]) ? 0 : $data[$code]) ); } @@ -171,7 +171,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes } $stringtoprint .= '
'; $this->info_box_contents[][]=array( - 'td' => 'center', + 'td' => 'class="center"', 'text' => $stringtoprint ); } else { diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index adcc750a6a8..afed778912f 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -60,7 +60,7 @@ class box_graph_product_distribution extends ModeleBoxes $this->db = $db; $this->hidden = !( - (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + (isModEnabled('facture') && !empty($user->rights->facture->lire)) || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); @@ -107,7 +107,7 @@ class box_graph_product_distribution extends ModeleBoxes $showinvoicenb = 1; $showordernb = 1; } - if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) { + if (!isModEnabled('facture') || empty($user->rights->facture->lire)) { $showinvoicenb = 0; } if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) { @@ -278,7 +278,7 @@ class box_graph_product_distribution extends ModeleBoxes } - if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { + if (isModEnabled('facture') && !empty($user->rights->facture->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showinvoicenb) { $langs->load("bills"); @@ -372,7 +372,7 @@ class box_graph_product_distribution extends ModeleBoxes if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire)) { $stringtoshow .= ' '.$langs->trans("ForCustomersOrders"); } - if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) { + if (isModEnabled('facture') || !empty($user->rights->facture->lire)) { $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); $stringtoshow .= '   '; } diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 5e69a49e88e..c668894d991 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -152,7 +152,7 @@ class box_graph_ticket_by_severity extends ModeleBoxes } foreach ($listofoppcode as $rowid => $code) { $dataseries[] = array( - 'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_category', 'code', 'label', $code), + 'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_severity', 'code', 'label', $code), 'data' => (empty($data[$code]) ? 0 : $data[$code]) ); } @@ -191,19 +191,19 @@ class box_graph_ticket_by_severity extends ModeleBoxes } $stringtoprint .= ''; $this->info_box_contents[][]=array( - 'td' => 'center', + 'td' => 'class="center"', 'text' => $stringtoprint ); } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="center opacitymedium"', - 'text' => $langs->trans("BoxNoTicketSeverity") + 'td' => '', + 'text' => ''.$langs->trans("BoxNoTicketSeverity").'' ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'', ); } } diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 300a13803c5..fd8ecd95eaf 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -177,15 +177,15 @@ class box_last_modified_ticket extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + $this->info_box_contents[$i][0] = array('td' => '', 'text'=>''.$langs->trans("BoxLastModifiedTicketNoRecordedTickets").''); } } else { dol_print_error($this->db); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'', ); } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 25cb353b268..41ac39c1239 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -85,9 +85,9 @@ class box_last_ticket extends ModeleBoxes ); if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut as status, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email,"; + $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label,"; + $sql .= " s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; @@ -113,6 +113,7 @@ class box_last_ticket extends ModeleBoxes while ($i < $num) { $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); //$dateterm = $this->db->jdate($objp->fin_validite); //$dateclose = $this->db->jdate($objp->date_close); @@ -122,7 +123,8 @@ class box_last_ticket extends ModeleBoxes $ticket->id = $objp->id; $ticket->track_id = $objp->track_id; $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; + $ticket->fk_statut = $objp->status; + $ticket->status = $objp->status; $ticket->subject = $objp->subject; if ($objp->fk_soc > 0) { $thirdparty = new Societe($this->db); @@ -149,8 +151,8 @@ class box_last_ticket extends ModeleBoxes // Subject $this->info_box_contents[$i][$r] = array( 'td' => 'class="tdoverflowmax200"', - 'text' => ''.$objp->subject.'', // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + 'text' => ''.dol_escape_htmltag($objp->subject).'', // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".urlencode($objp->track_id), ); $r++; @@ -180,14 +182,14 @@ class box_last_ticket extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); + $this->info_box_contents[$i][0] = array('td' => '', 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").''); } } else { dol_print_error($this->db); } } else { - $this->info_box_contents[0][0] = array('td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array('td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").''); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php deleted file mode 100644 index 5865cba2530..00000000000 --- a/htdocs/core/boxes/box_members.php +++ /dev/null @@ -1,195 +0,0 @@ - - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic 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 . - */ - -/** - * \file htdocs/core/boxes/box_members.php - * \ingroup adherent - * \brief Module to show box of members - */ - -include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; - - -/** - * Class to manage the box to show last members - */ -class box_members extends ModeleBoxes -{ - public $boxcode = "lastmembers"; - public $boximg = "object_user"; - public $boxlabel = "BoxLastMembers"; - public $depends = array("adherent"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - public $enabled = 1; - - public $info_box_head = array(); - public $info_box_contents = array(); - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user; - - $this->db = $db; - - // disable module for such cases - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { - $this->enabled = 0; // disabled for external users - } - - $this->hidden = !($user->rights->adherent->lire); - } - - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->load("boxes"); - - $this->max = $max; - - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); - - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); - - if ($user->rights->adherent->lire) { - $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; - $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; - $sql .= ' a.photo, a.email, a.gender, a.morphy,'; - $sql .= " t.subscription, t.libelle as label"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql .= " WHERE a.entity IN (".getEntity('member').")"; - $sql .= " AND a.fk_adherent_type = t.rowid"; - $sql .= " ORDER BY a.tms DESC"; - $sql .= $this->db->plimit($max, 0); - - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); - - $memberstatic->lastname = $objp->lastname; - $memberstatic->firstname = $objp->firstname; - $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->ref; - $memberstatic->photo = $objp->photo; - $memberstatic->gender = $objp->gender; - $memberstatic->email = $objp->email; - $memberstatic->morphy = $objp->morphy; - $memberstatic->company = $objp->company; - $memberstatic->statut = $objp->status; - $memberstatic->date_creation = $datec; - $memberstatic->date_modification = $datem; - $memberstatic->need_subscription = $objp->subscription; - $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); - - if (!empty($objp->fk_soc)) { - $memberstatic->socid = $objp->fk_soc; - $memberstatic->fetch_thirdparty(); - $memberstatic->name = $memberstatic->thirdparty->name; - } else { - $memberstatic->name = $objp->company; - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->getNomUrl(-1), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->company, - 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($datem, "day", 'tzuserrel'), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), - ); - - $line++; - } - - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), - ); - } - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium 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_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index cf70bcafcb1..91ce3c93c36 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -28,7 +28,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; /** - * Class to manage the box to show last modofied members + * Class to manage the box to show last modified members */ class box_members_last_modified extends ModeleBoxes { @@ -92,7 +92,7 @@ class box_members_last_modified extends ModeleBoxes if ($user->rights->adherent->lire) { $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; - $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql .= " a.datec, a.tms as datem, a.statut as status, a.datefin as date_end_subscription,"; $sql .= ' a.photo, a.email, a.gender, a.morphy,'; $sql .= " t.rowid as typeid, t.subscription, t.libelle as label"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; @@ -109,7 +109,7 @@ class box_members_last_modified extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->datem); $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; @@ -121,6 +121,8 @@ class box_members_last_modified extends ModeleBoxes $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; $memberstatic->statut = $objp->status; + $memberstatic->date_creation = $datec; + $memberstatic->date_modification = $datem; $memberstatic->need_subscription = $objp->subscription; $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); if (!empty($objp->fk_soc)) { @@ -140,6 +142,11 @@ class box_members_last_modified extends ModeleBoxes 'asis' => 1, ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' =>$memberstatic->company, + ); + $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $statictype->getNomUrl(1, 32), @@ -147,7 +154,7 @@ class box_members_last_modified extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 6436fb8e34e..cff19388c17 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -144,7 +144,7 @@ class box_mos extends ModeleBoxes } $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 63a4e90cdd0..909ff32acb9 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -84,6 +84,7 @@ class box_project extends ModeleBoxes $textHead = $langs->trans("OpenedProjects"); $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $i = 0; // list the summary of the orders if ($user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -113,7 +114,6 @@ class box_project extends ModeleBoxes if ($result) { $num = $this->db->num_rows($result); - $i = 0; while ($i < min($num, $max)) { $objp = $this->db->fetch_object($result); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index f3f9496325f..97b7bd5fd51 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -165,7 +165,7 @@ class box_propales extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzuserrel')).'"', 'text' => dol_print_date($date, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index b6acbbbfbc9..94fb05d5346 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -597,7 +597,7 @@ class CMailFile } $sendingmode = $this->sendmode; - if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { + if ($this->sendcontext == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { // List of sending methods $listofmethods = array(); $listofmethods['mail'] = 'PHP mail function'; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index a4414fa6edb..67443a7bdb8 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -151,7 +151,7 @@ class Canvas public function assign_values(&$action = 'view', $id = 0, $ref = '') { // phpcs:enable - if (method_exists($this->control, 'assign_values')) { + if (is_object($this->control) && method_exists($this->control, 'assign_values')) { $this->control->assign_values($action, $id, $ref); } } diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php new file mode 100644 index 00000000000..ab1023b81f5 --- /dev/null +++ b/htdocs/core/class/cgenericdic.class.php @@ -0,0 +1,478 @@ + + * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * + * 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/core/class/cgenericdic.class.php + * \ingroup resource + */ + +/** + * Class CGenericDic + * + * @see CommonObject + */ +class CGenericDic +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'undefined'; // Will be defined into constructor + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'undefined'; // Will be defined into constructor + + /** + * @var CtyperesourceLine[] Lines + */ + public $lines = array(); + + public $code; + + /** + * @var string Type resource label + */ + public $label; + + public $active; + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + + // Don't forget to set this->element and this->table_element after the construction + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldlabel = 'libelle'; + } + + $error = 0; + + // Clean parameters + + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + // Insert request + $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'('; + $sql .= 'code,'; + $sql .= $fieldlabel; + $sql .= 'active'; + $sql .= ') VALUES ('; + $sql .= ' '.(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").','; + $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; + $sql .= ' '.(!isset($this->active) ? 'NULL' : $this->active); + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element); + + // Uncomment this and change CTYPERESOURCE to your own tag if you + // want this action to call a trigger. + //if (!$notrigger) { + + // // Call triggers + // $result=$this->call_trigger('CTYPERESOURCE_CREATE',$user); + // if ($result < 0) $error++; + // // End call triggers + //} + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return -1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $code code + * @param string $label Label + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $code = '', $label = '') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldrowid = 'id'; + $fieldlabel = 'libelle'; + } + + $sql = "SELECT"; + $sql .= " t.".$fieldrowid.","; + $sql .= " t.code,"; + $sql .= " t.".$fieldlabel." as label,"; + $sql .= " t.active"; + $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + if ($id) { + $sql .= " WHERE t.".$fieldrowid." = ".((int) $id); + } elseif ($code) { + $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + } elseif ($label) { + $sql .= " WHERE t.label = '".$this->db->escape($label)."'"; + } + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->$fieldrowid; + + $this->code = $obj->code; + $this->label = $obj->label; + $this->active = $obj->active; + } + + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + // $this->fetch_optionals(); + + // $this->fetch_lines(); + + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldrowid = 'id'; + $fieldlabel = 'libelle'; + } + + $sql = "SELECT"; + $sql .= " t.".$fieldrowid.","; + $sql .= " t.code,"; + $sql .= " t.".$fieldlabel." as label,"; + $sql .= " t.active"; + $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + } + } + + if (count($sqlwhere) > 0) { + $sql .= " WHERE ".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new self($this->db); + + $line->id = $obj->$fieldrowid; + + $line->code = $obj->code; + $line->label = $obj->label; + $line->active = $obj->active; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldrowid = 'id'; + $fieldlabel = 'libelle'; + } + + // Clean parameters + + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET'; + $sql .= " code = ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").','; + $sql .= " ".$fieldlabel." = ".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; + $sql .= " active = ".(isset($this->active) ? $this->active : "null"); + $sql .= " WHERE ".$fieldrowid." = ".((int) $this->id); + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + + // Uncomment this and change CTYPERESOURCE to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { + + // // Call triggers + // $result=$this->call_trigger('CTYPERESOURCE_MODIFY',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return -1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + + $error = 0; + + $this->db->begin(); + + // Uncomment this and change CTYPERESOURCE to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { + + // // Call triggers + // $result=$this->call_trigger('CTYPERESOURCE_DELETE',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} + + // If you need to delete child tables to, you can insert them here + + if (!$error) { + $sql = "DELETE FROM ".$this->db->prefix().$this->table_element; + $sql .= " WHERE ".$fieldrowid." = ".((int) $this->id); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return -1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromClone(User $user, $fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + $object = new Ctyperesource($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error++; + $this->errors = $object->errors; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return -1; + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->code = 'CODE'; + $this->label = 'Label'; + $this->active = 1; + } +} diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a9536f410ca..bee63613bca 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -65,6 +65,26 @@ abstract class CommonDocGenerator */ public $scandir; + public $page_hauteur; + public $page_largeur; + public $marge_gauche; + public $marge_droite; + public $marge_haute; + public $marge_basse; + + public $option_logo; + public $option_tva; + public $option_multilang; + public $option_freetext; + public $option_draft_watermark; + + public $option_modereg; + public $option_condreg; + public $option_escompte; + public $option_credit_note; + + public $emetteur; + /** * Constructor @@ -427,8 +447,9 @@ abstract class CommonDocGenerator $resarray = array( $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref' => (property_exists($object, 'ref') ? $object->ref : ''), + $array_key.'_label' => (property_exists($object, 'label') ? $object->label : ''), + $array_key.'_ref_ext' => (property_exists($object, 'ref_ext') ? $object->ref_ext : ''), $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), $array_key.'_source_invoice_ref'=>$invoice_source->ref, @@ -449,7 +470,7 @@ abstract class CommonDocGenerator $array_key.'_payment_term_code'=>$object->cond_reglement_code, $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), - $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), + $array_key.'_incoterms' => (method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), $array_key.'_bank_iban'=>$bank_account->iban, $array_key.'_bank_bic'=>$bank_account->bic, @@ -592,6 +613,7 @@ abstract class CommonDocGenerator 'line_product_label'=>(empty($line->product_label) ? '' : $line->product_label), 'line_product_type'=>(empty($line->product_type) ? '' : $line->product_type), 'line_product_barcode'=>(empty($line->product_barcode) ? '' : $line->product_barcode), + 'line_product_desc'=>(empty($line->product_desc) ? '' : $line->product_desc), 'line_desc'=>$line->desc, 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), @@ -813,25 +835,38 @@ abstract class CommonDocGenerator * * @param Object $object Dolibarr Object * @param Translate $outputlangs Language object for output - * @param boolean $recursive Want to fetch child array or child object + * @param boolean|int $recursive Want to fetch child array or child object. * @return array Array of substitution key->code */ - public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = 1) { // phpcs:enable $array_other = array(); if (!empty($object)) { foreach ($object as $key => $value) { + if (in_array($key, array('db', 'fields', 'lines', 'modelpdf', 'model_pdf'))) { // discard some properties + continue; + } if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; - } - if (is_array($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + } elseif (is_array($value) && $recursive) { + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } + } elseif (is_object($value) && $recursive) { + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } } } + + //var_dump($array_other); + return $array_other; } diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index e74d1428781..6c707141774 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -64,7 +64,9 @@ trait CommonIncoterm $result = $this->db->query($sql); if ($result) { $res = $this->db->fetch_object($result); - $out .= $res->code; + if ($res) { + $out .= $res->code; + } } } @@ -76,7 +78,7 @@ trait CommonIncoterm /** * Return incoterms informations for pdf display * - * @return string incoterms info + * @return string|boolean Incoterms info or false */ public function getIncotermsForPDF() { @@ -86,7 +88,11 @@ trait CommonIncoterm $num = $this->db->num_rows($resql); if ($num > 0) { $res = $this->db->fetch_object($resql); - return 'Incoterm : '.$res->code.' - '.$this->location_incoterms; + if ($res) { + return 'Incoterm : '.$res->code.' - '.$this->location_incoterms; + } else { + return $res; + } } else { return ''; } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index e49f8a6a728..06d352441be 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -93,12 +93,17 @@ abstract class CommonInvoice extends CommonObject const STATUS_ABANDONED = 3; + public $totalpaid; // duplicate with sumpayed + public $totaldeposits; // duplicate with sumdeposit + public $totalcreditnotes; // duplicate with sumcreditnote + public $sumpayed; public $sumpayed_multicurrency; public $sumdeposit; public $sumdeposit_multicurrency; public $sumcreditnote; public $sumcreditnote_multicurrency; + public $remaintopay; /** @@ -737,17 +742,17 @@ abstract class CommonInvoice extends CommonObject if ($row[0] == 0) { $now = dol_now(); - $totalpaye = $this->getSommePaiement(); + $totalpaid = $this->getSommePaiement(); $totalcreditnotes = $this->getSumCreditNotesUsed(); $totaldeposits = $this->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($this->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); if (empty($amount)) { - $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $amount = price2num($this->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); } if (is_numeric($amount) && $amount != 0) { @@ -843,7 +848,7 @@ abstract class CommonInvoice extends CommonObject */ public function buildZATCAQRString() { - global $conf; + global $conf, $mysoc; $tmplang = new Translate('', $conf); $tmplang->setDefaultLang('en_US'); @@ -862,11 +867,11 @@ abstract class CommonInvoice extends CommonObject $pricewithtax = implode(unpack("H*", price2num($pricewithtaxstring, 2))); $pricetax = implode(unpack("H*", $pricetaxstring)); - var_dump(strlen($this->thirdparty->name)); - var_dump(str_pad(dechex('9'), 2, '0', STR_PAD_LEFT)); - var_dump($this->thirdparty->name); - var_dump(implode(unpack("H*", $this->thirdparty->name))); - var_dump(price($this->total_tva, 0, $tmplang, 0, -1, 2)); + //var_dump(strlen($this->thirdparty->name)); + //var_dump(str_pad(dechex('9'), 2, '0', STR_PAD_LEFT)); + //var_dump($this->thirdparty->name); + //var_dump(implode(unpack("H*", $this->thirdparty->name))); + //var_dump(price($this->total_tva, 0, $tmplang, 0, -1, 2)); $s = '01'.str_pad(dechex(strlen($this->thirdparty->name)), 2, '0', STR_PAD_LEFT).$name; $s .= '02'.str_pad(dechex(strlen($this->thirdparty->tva_intra)), 2, '0', STR_PAD_LEFT).$vatnumber; @@ -880,8 +885,8 @@ abstract class CommonInvoice extends CommonObject */ // Using TLV format - $s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$this->thirdparty->name; - $s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$this->thirdparty->tva_intra; + $s = pack('C1', 1).pack('C1', strlen($mysoc->name)).$mysoc->name; + $s .= pack('C1', 2).pack('C1', strlen($mysoc->tva_intra)).$mysoc->tva_intra; $s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring; $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; $s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring; @@ -1079,4 +1084,6 @@ abstract class CommonInvoiceLine extends CommonObjectLine public $fk_user_author; public $fk_user_modif; + + public $fk_accounting_account; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7a4d105cfac..3fb25672bbe 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -115,6 +115,16 @@ abstract class CommonObject */ public $array_languages = null; // Value is array() when load already tried + /** + * @var array To store result of ->liste_contact() + */ + public $contacts_ids; + + /** + * @var mixed Array of linked objects, set and used when calling ->create() to be able to create links during the creation of object + */ + public $linked_objects; + /** * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked */ @@ -201,7 +211,7 @@ abstract class CommonObject public $user; /** - * @var string The type of originating object ('commande', 'facture', ...) + * @var string The type of originating object ('commande', 'facture', ...). Note: on some object this field is called $origin_type * @see fetch_origin() */ public $origin; @@ -1649,13 +1659,13 @@ abstract class CommonObject // phpcs:enable global $conf; - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) { + if (empty($this->socid) && empty($this->fk_soc) && empty($force_thirdparty_id)) { return 0; } require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); + $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : 0); if ($force_thirdparty_id) { $idtofetch = $force_thirdparty_id; } @@ -2236,10 +2246,14 @@ abstract class CommonObject * Link element with a project * * @param int $projectid Project id to link element to + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setProject($projectid) + public function setProject($projectid, $notrigger = 0) { + global $user; + $error = 0; + if (!$this->table_element) { dol_syslog(get_class($this)."::setProject was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -2270,13 +2284,33 @@ abstract class CommonObject $sql .= " WHERE rowid = ".((int) $this->id); } + $this->db->begin(); + dol_syslog(get_class($this)."::setProject", LOG_DEBUG); if ($this->db->query($sql)) { $this->fk_project = ((int) $projectid); - return 1; } else { dol_print_error($this->db); + $error++; + } + + // Triggers + if (!$error && !$notrigger) { + // Call triggers + $result = $this->call_trigger(strtoupper($this->element) . '_MODIFY', $user); + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); return -1; + } else { + $this->db->commit(); + return 1; } } @@ -2606,7 +2640,7 @@ abstract class CommonObject } if (empty($deposit_percent) || $deposit_percent < 0) { - $deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $id); + $deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $id); } if ($deposit_percent > 100) { @@ -2615,7 +2649,9 @@ abstract class CommonObject $sql = 'UPDATE '.$this->db->prefix().$this->table_element; $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); - $sql .= " , deposit_percent = " . (! empty($deposit_percent) ? "'".$this->db->escape($deposit_percent)."'" : 'NULL'); + if (in_array($this->table_element, array('propal', 'commande'))) { + $sql .= " , deposit_percent = " . (empty($deposit_percent) ? 'NULL' : "'".$this->db->escape($deposit_percent)."'"); + } $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -4855,7 +4891,7 @@ abstract class CommonObject $product_static->fetch($line->fk_product); $product_static->ref = $line->ref; //can change ref in hook - $product_static->label = $line->label; //can change label in hook + $product_static->label = !empty($line->label) ? $line->label : ""; //can change label in hook $text = $product_static->getNomUrl(1); @@ -4891,7 +4927,7 @@ abstract class CommonObject $description .= (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. } - $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU'); + $line->pu_ttc = price2num((!empty($line->subprice) ? $line->subprice : 0) * (1 + ((!empty($line->tva_tx) ? $line->tva_tx : 0) / 100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer @@ -6112,7 +6148,7 @@ abstract class CommonObject //var_dump($this->oldcopy);exit; if (is_object($this->oldcopy)) { // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); - if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) { // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. + if (isset($this->oldcopy->array_options[$key]) && $this->array_options[$key] == $this->oldcopy->array_options[$key]) { // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. $new_array_options[$key] = $this->array_options[$key]; // Value is kept } else { // var_dump($algo); @@ -6816,7 +6852,7 @@ abstract class CommonObject if ((string) $key == '') { continue; } - list($val, $parent) = explode('|', $val); + if (strpos($val, "|") !== false) list($val, $parent) = explode('|', $val); $out .= '